Skip to content

Commit 0ae8768

Browse files
committed
fix: Update Dockerfile templates to use --no-install-recommends for package installations
1 parent 5bf7f5b commit 0ae8768

File tree

6 files changed

+139
-44
lines changed

6 files changed

+139
-44
lines changed

.github/workflows/feelpp-env.yml

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- {service: feelpp-env, dist: testing, flavor: debian, version: "testing", tag: debian-testing, experimental: true, platforms: "linux/amd64", dockerfile: Dockerfile}
6060
- {service: feelpp-env, dist: sid, flavor: debian, version: "sid", tag: debian-sid, experimental: true, platforms: "linux/amd64,linux/arm64", dockerfile: Dockerfile}
6161
- {service: feelpp-env, dist: noble, flavor: ubuntu, version: "24.04", tag: ubuntu-24.04, experimental: false, platforms: "linux/amd64,linux/arm64", dockerfile: Dockerfile}
62-
- {service: feelpp-env, dist: oracular, flavor: ubuntu, version: "26.04", tag: ubuntu-26.04, experimental: true, platforms: "linux/amd64,linux/arm64", dockerfile: Dockerfile}
62+
# ubuntu-26.04 disabled: resolute repositories not yet available on mirrors
6363
- {service: feelpp-env, dist: fedora-42, flavor: fedora, version: "42", tag: fedora-42, experimental: false, platforms: "linux/amd64", dockerfile: Dockerfile}
6464
runs-on: self-docker
6565
needs: activate
@@ -76,25 +76,16 @@ jobs:
7676
enable-cache: true
7777
- name: Setup Python factory
7878
run: |
79-
if [ -f "feelpp-env/factory.sh" ]; then
80-
echo "Setting up Python factory environment..."
81-
cd feelpp-env
82-
uv venv .venv
83-
source .venv/bin/activate
84-
uv pip install -q pyyaml jinja2 click rich pydantic
85-
./factory.sh validate || echo "Validation skipped"
86-
fi
79+
echo "Setting up Python factory environment..."
80+
cd feelpp-env
81+
uv venv .venv
82+
source .venv/bin/activate
83+
uv pip install -q pyyaml jinja2 click rich pydantic
84+
./factory.sh validate
8785
- name: generate
8886
run: |
89-
# Try Python factory first, fallback to bash script
90-
if [ -x "./factory.sh" ] && [ -d "config" ]; then
91-
echo "Using Python factory..."
92-
./factory.sh generate --dist ${{ matrix.flavor }}:${{ matrix.version }}
93-
dir="${{ matrix.flavor }}-${{ matrix.version }}-clang++"
94-
else
95-
echo "Using bash mkimg.sh..."
96-
dir="$(bash mkimg.sh -f ${{ matrix.flavor }}:${{ matrix.version }} -t feelpp/${{ matrix.service }}:${{ matrix.tag }})"
97-
fi
87+
./factory.sh generate --dist ${{ matrix.flavor }}:${{ matrix.version }}
88+
dir="${{ matrix.flavor }}-${{ matrix.version }}-clang++"
9889
echo "context=feelpp-env/${dir}" >> "$GITHUB_OUTPUT"
9990
ls -lrt
10091
id: generate
@@ -143,25 +134,16 @@ jobs:
143134
enable-cache: true
144135
- name: Setup Python factory
145136
run: |
146-
if [ -f "feelpp-env/factory.sh" ]; then
147-
echo "Setting up Python factory environment..."
148-
cd feelpp-env
149-
uv venv .venv
150-
source .venv/bin/activate
151-
uv pip install -q pyyaml jinja2 click rich pydantic
152-
./factory.sh validate || echo "Validation skipped"
153-
fi
137+
echo "Setting up Python factory environment..."
138+
cd feelpp-env
139+
uv venv .venv
140+
source .venv/bin/activate
141+
uv pip install -q pyyaml jinja2 click rich pydantic
142+
./factory.sh validate
154143
- name: generate
155144
run: |
156-
# Try Python factory first, fallback to bash script
157-
if [ -x "./factory.sh" ] && [ -d "config" ]; then
158-
echo "Using Python factory..."
159-
./factory.sh generate --dist ${{ inputs.flavor }}:${{ inputs.version }}
160-
dir="${{ inputs.flavor }}-${{ inputs.version }}-clang++"
161-
else
162-
echo "Using bash mkimg.sh..."
163-
dir="$(bash mkimg.sh -f ${{ inputs.flavor }}:${{ inputs.version }} -t feelpp/${{ env.service }}:${{ env.tag }})"
164-
fi
145+
./factory.sh generate --dist ${{ inputs.flavor }}:${{ inputs.version }}
146+
dir="${{ inputs.flavor }}-${{ inputs.version }}-clang++"
165147
echo "context=feelpp-env/${dir}" >> "$GITHUB_OUTPUT"
166148
ls -lrt
167149
id: generate

feelpp-env/config/distributions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ distributions:
22
debian:
33
package_manager: apt
44
template: debian.dockerfile.j2
5-
mirror: ftp.fr.debian.org
5+
mirror: miroir.univ-lorraine.fr
66
versions:
77
- name: trixie
88
tag: "13"

feelpp-env/config/variants.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ variants:
1414
- debian:testing
1515
- debian:sid
1616
- ubuntu:24.04
17-
- ubuntu:26.04
17+
# - ubuntu:26.04 # Disabled: resolute repositories not yet available on mirrors
1818
- fedora:42
1919
extra_packages:
2020
apt: []

feelpp-env/factory/cli.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Command-line interface for Feel++ Docker factory."""
33

44
import sys
5+
import subprocess
56
from pathlib import Path
67
from typing import Optional
78

@@ -219,6 +220,118 @@ def matrix(ctx, variant: str, format: str):
219220
sys.exit(1)
220221

221222

223+
@main.command()
224+
@click.argument('dist', required=True)
225+
@click.option('--variant', default='feelpp-env', help='Variant to build')
226+
@click.option('--tag', help='Docker tag (default: feelpp-env:DIST-VERSION)')
227+
@click.option('--platform', help='Platform to build for (e.g., linux/amd64)')
228+
@click.option('--no-cache', is_flag=True, help='Build without using cache')
229+
@click.option('--output-dir', type=click.Path(path_type=Path),
230+
default=Path.cwd(),
231+
help='Directory containing generated Dockerfiles')
232+
@click.pass_context
233+
def build(ctx, dist: str, variant: str, tag: Optional[str],
234+
platform: Optional[str], no_cache: bool, output_dir: Path):
235+
"""Build Docker image locally for testing.
236+
237+
DIST should be in format 'name:version' (e.g., ubuntu:24.04, debian:13)
238+
239+
Examples:
240+
241+
# Build Ubuntu 24.04 image
242+
./factory.sh build ubuntu:24.04
243+
244+
# Build with custom tag
245+
./factory.sh build debian:13 --tag test:debian-13
246+
247+
# Build for specific platform
248+
./factory.sh build ubuntu:24.04 --platform linux/amd64
249+
250+
# Build without cache
251+
./factory.sh build fedora:42 --no-cache
252+
"""
253+
config: Config = ctx.obj['config']
254+
builder: ImageBuilder = ctx.obj['builder']
255+
256+
if variant not in config.variants:
257+
console.print(f"[red]Error:[/red] Unknown variant '{variant}'")
258+
console.print(f"Available variants: {', '.join(config.variants.keys())}")
259+
sys.exit(1)
260+
261+
try:
262+
dist_name, version_tag = dist.split(':')
263+
except ValueError:
264+
console.print(f"[red]Error:[/red] DIST must be in format 'name:version' (got '{dist}')")
265+
console.print("Examples: ubuntu:24.04, debian:13, fedora:42")
266+
sys.exit(1)
267+
268+
# Check if Dockerfile exists, generate if not
269+
dockerfile_dir = output_dir / f"{dist_name}-{version_tag}-clang++"
270+
dockerfile_path = dockerfile_dir / "Dockerfile"
271+
272+
if not dockerfile_path.exists():
273+
console.print(f"[yellow]Dockerfile not found, generating...[/yellow]")
274+
try:
275+
builder.generate_dockerfile(variant, dist_name, version_tag, dockerfile_dir)
276+
console.print(f"[green]✓[/green] Generated {dockerfile_path}")
277+
except Exception as e:
278+
console.print(f"[red]Error generating Dockerfile:[/red] {e}")
279+
sys.exit(1)
280+
281+
# Prepare Docker build command
282+
if not tag:
283+
tag = f"feelpp-env:{dist_name}-{version_tag}"
284+
285+
build_cmd = [
286+
"docker", "build",
287+
"-t", tag,
288+
"-f", str(dockerfile_path),
289+
]
290+
291+
if platform:
292+
build_cmd.extend(["--platform", platform])
293+
294+
if no_cache:
295+
build_cmd.append("--no-cache")
296+
297+
# Context is the directory containing the Dockerfile
298+
build_cmd.append(str(dockerfile_dir))
299+
300+
console.print(f"\n[blue]Building Docker image:[/blue]")
301+
console.print(f" Distribution: {dist}")
302+
console.print(f" Tag: {tag}")
303+
console.print(f" Dockerfile: {dockerfile_path}")
304+
if platform:
305+
console.print(f" Platform: {platform}")
306+
console.print()
307+
308+
# Show the command
309+
console.print(f"[dim]$ {' '.join(build_cmd)}[/dim]\n")
310+
311+
# Run Docker build
312+
try:
313+
result = subprocess.run(
314+
build_cmd,
315+
check=False,
316+
cwd=dockerfile_dir.parent
317+
)
318+
319+
if result.returncode == 0:
320+
console.print(f"\n[green]✓ Successfully built {tag}[/green]")
321+
console.print(f"\nTo run the image:")
322+
console.print(f" docker run -it --rm {tag}")
323+
else:
324+
console.print(f"\n[red]✗ Build failed with exit code {result.returncode}[/red]")
325+
sys.exit(result.returncode)
326+
327+
except FileNotFoundError:
328+
console.print("[red]Error:[/red] Docker command not found. Is Docker installed?")
329+
sys.exit(1)
330+
except KeyboardInterrupt:
331+
console.print("\n[yellow]Build interrupted by user[/yellow]")
332+
sys.exit(130)
333+
334+
222335
@main.command()
223336
@click.option('--variant', default='feelpp-env', help='Variant to update CI for')
224337
@click.option('--workflow-file', type=click.Path(path_type=Path),

feelpp-env/templates/debian.dockerfile.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ RUN set -e; \
2121

2222
# Install core dependencies
2323
RUN apt-get -qq update && \
24-
apt-get -y install \
24+
apt-get -y install --no-install-recommends \
2525
gnupg \
2626
ca-certificates-java default-jre-headless
2727

2828
# Set timezone
2929
ARG DEBIAN_FRONTEND=noninteractive
3030
ENV TZ=Europe/Paris
31-
RUN apt-get -y install tzdata
31+
RUN apt-get -y install --no-install-recommends tzdata
3232

3333
# Install all packages
3434
RUN apt-get -qq update && \
35-
apt-get -y install \
35+
apt-get -y install --no-install-recommends \
3636
{{ packages | join_packages(8) }}
3737
&& apt-get autoremove \
3838
&& apt-get clean \
@@ -41,7 +41,7 @@ RUN apt-get -qq update && \
4141
{% if enable_openmpi and requires_openmpi_layer %}
4242
# Install OpenMPI
4343
RUN apt-get -qq update && \
44-
apt-get -y install \
44+
apt-get -y install --no-install-recommends \
4545
libopenmpi-dev \
4646
openmpi-bin \
4747
&& apt-get autoremove \

feelpp-env/templates/ubuntu.dockerfile.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ RUN sed -i 's/http:\/\/archive.ubuntu.com\/ubuntu\//http:\/\/miroir.univ-lorrain
1111
ARG DEBIAN_FRONTEND=noninteractive
1212
ENV TZ=Europe/Paris
1313
RUN apt-get -qq update && \
14-
apt-get -y --force-yes install tzdata software-properties-common \
14+
apt-get -y --force-yes install --no-install-recommends tzdata software-properties-common \
1515
&& apt-get -y autoremove \
1616
&& apt-get -y clean \
1717
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1818

1919
# Install all packages
2020
RUN apt-get -qq update && \
21-
apt-get -yq install \
21+
apt-get -y install --no-install-recommends \
2222
{{ packages | join_packages(8) }}
2323
&& apt-get -y autoremove \
2424
&& apt-get -y clean \
@@ -27,7 +27,7 @@ RUN apt-get -qq update && \
2727
{% if enable_openmpi and requires_openmpi_layer %}
2828
# Install OpenMPI
2929
RUN apt-get -qq update && \
30-
apt-get -yq install \
30+
apt-get -y install --no-install-recommends \
3131
libopenmpi-dev \
3232
openmpi-bin \
3333
&& apt-get -y autoremove \

0 commit comments

Comments
 (0)