Skip to content

Commit e7acff6

Browse files
authored
Dockerfile: remove dnf cache to save space (#222)
1 parent 494670b commit e7acff6

File tree

1 file changed

+97
-28
lines changed

1 file changed

+97
-28
lines changed

Dockerfile

Lines changed: 97 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
2121
# - Tools for creating a CRAFF image to load into a model
2222
# - Python, including checkers/linters
2323
# - Rust (will be on the PATH due to the ENV command above)
24-
RUN dnf -y update && \
25-
dnf -y install \
24+
# hadolint ignore=DL3004,SC3009
25+
RUN <<EOF
26+
set -e
27+
# Update system packages
28+
dnf -y update
29+
30+
# Install system dependencies
31+
dnf -y install \
2632
alsa-lib \
2733
atk \
2834
awk \
@@ -60,31 +66,52 @@ RUN dnf -y update && \
6066
python3 \
6167
python3-pip \
6268
vim \
63-
yamllint && \
64-
python3 -m pip install --no-cache-dir \
69+
yamllint
70+
71+
# Install Python packages
72+
python3 -m pip install --no-cache-dir \
6573
black==23.10.1 \
6674
flake8==6.1.0 \
6775
isort==5.12.0 \
6876
mypy==1.6.1 \
69-
pylint==3.0.2 && \
70-
curl https://sh.rustup.rs -sSf | bash -s -- --default-toolchain none -y
77+
pylint==3.0.2
78+
79+
# Install Rust
80+
curl https://sh.rustup.rs -sSf | bash -s -- --default-toolchain none -y
81+
82+
# Clean up package manager cache
83+
dnf clean all
84+
rm -rf /var/cache/dnf/* /tmp/* /var/tmp/*
85+
EOF
7186

7287

7388
WORKDIR /workspace
7489

7590
# Download and install public SIMICS. This installs all the public packages as well as the
7691
# ispm SIMICS package and project manager. ISPM will be on the path due to the ENV command
7792
# above
78-
RUN mkdir -p /workspace/simics/ispm/ && \
79-
curl --noproxy '*.intel.com' -L -o /workspace/simics/ispm.tar.gz "${PUBLIC_SIMICS_ISPM_URL}" && \
80-
curl --noproxy '*.intel.com' -L -o /workspace/simics/simics.ispm "${PUBLIC_SIMICS_PKGS_URL}" && \
81-
tar -C /workspace/simics/ispm --strip-components=1 \
82-
-xf /workspace/simics/ispm.tar.gz && \
83-
ispm settings install-dir /workspace/simics && \
84-
ispm packages --install-bundle /workspace/simics/simics.ispm --non-interactive \
85-
--trust-insecure-packages && \
86-
rm /workspace/simics/ispm.tar.gz /workspace/simics/simics.ispm && \
87-
rm -rf /workspace/simics-6-packages/
93+
# hadolint ignore=DL3004,SC3009
94+
RUN <<EOF
95+
set -e
96+
# Create directories
97+
mkdir -p /workspace/simics/ispm/
98+
99+
# Download SIMICS components
100+
curl --noproxy '*.intel.com' -L -o /workspace/simics/ispm.tar.gz "${PUBLIC_SIMICS_ISPM_URL}"
101+
curl --noproxy '*.intel.com' -L -o /workspace/simics/simics.ispm "${PUBLIC_SIMICS_PKGS_URL}"
102+
103+
# Extract and install
104+
tar -C /workspace/simics/ispm --strip-components=1 -xf /workspace/simics/ispm.tar.gz
105+
rm /workspace/simics/ispm.tar.gz
106+
107+
# Configure and install packages
108+
ispm settings install-dir /workspace/simics
109+
ispm packages --install-bundle /workspace/simics/simics.ispm --non-interactive --trust-insecure-packages
110+
111+
# Clean up
112+
rm /workspace/simics/simics.ispm
113+
rm -rf /tmp/* /var/tmp/*
114+
EOF
88115

89116
# Copy the local repository into the workspace
90117
COPY . /workspace/tsffs/
@@ -94,11 +121,20 @@ WORKDIR /workspace/tsffs/
94121
# Build the project by initializing it as a project associated with the local SIMICS installation
95122
# and building the module using the build script. Then, install the built TSFFS SIMICS
96123
# package into the local SIMICS installation for use.
97-
RUN cargo install cargo-simics-build && \
98-
cargo simics-build -r && \
99-
ispm packages \
100-
-i target/release/*-linux64.ispm \
101-
--non-interactive --trust-insecure-packages
124+
RUN <<EOF
125+
set -e
126+
# Install cargo-simics-build
127+
cargo install cargo-simics-build
128+
129+
# Build the project
130+
cargo simics-build -r
131+
132+
# Install the built package
133+
ispm packages -i target/release/*-linux64.ispm --non-interactive --trust-insecure-packages
134+
135+
# Cleanup
136+
cargo clean
137+
EOF
102138

103139
WORKDIR /workspace/projects/example/
104140

@@ -111,17 +147,26 @@ WORKDIR /workspace/projects/example/
111147
# - A built EFI application (test.efi) which checks a password and crashes when it gets the
112148
# password "fuzzing!"
113149
# - A SIMICS script that configures the fuzzer for the example and starts fuzzing it
114-
RUN ispm projects /workspace/projects/example/ --create \
150+
# hadolint ignore=DL3004,SC3009
151+
RUN <<EOF
152+
set -e
153+
# Create the example project
154+
ispm projects /workspace/projects/example/ --create \
115155
1000-${PUBLIC_SIMICS_PACKAGE_VERSION_1000} \
116156
2096-latest \
117157
8112-latest \
118158
1030-latest \
119-
31337-latest --ignore-existing-files --non-interactive && \
120-
cp /workspace/tsffs/examples/docker-example/fuzz.simics /workspace/projects/example/ && \
121-
cp /workspace/tsffs/tests/rsrc/minimal_boot_disk.craff /workspace/projects/example/ && \
122-
cp /workspace/tsffs/tests/rsrc/x86_64-uefi/* /workspace/projects/example/ && \
123-
cp /workspace/tsffs/harness/tsffs.h /workspace/projects/example/ && \
124-
ninja
159+
31337-latest --ignore-existing-files --non-interactive
160+
161+
# Copy required files
162+
cp /workspace/tsffs/examples/docker-example/fuzz.simics /workspace/projects/example/
163+
cp /workspace/tsffs/tests/rsrc/minimal_boot_disk.craff /workspace/projects/example/
164+
cp /workspace/tsffs/tests/rsrc/x86_64-uefi/* /workspace/projects/example/
165+
cp /workspace/tsffs/harness/tsffs.h /workspace/projects/example/
166+
167+
# Build the project
168+
ninja
169+
EOF
125170

126171
RUN echo 'echo "To run the demo, run ./simics -no-gui --no-win fuzz.simics"' >> /root/.bashrc
127172

@@ -164,6 +209,30 @@ WORKDIR /workspace/tsffs
164209

165210
FROM fedora:42@sha256:f357623dc40edf7803f21b2b954f92417f274a7370f82384ef13c73e08ce1727 AS tsffs-prod
166211

212+
# Install minimal runtime dependencies only
213+
# hadolint ignore=DL3004,SC3009
214+
RUN <<EOF
215+
set -e
216+
# Update system packages
217+
dnf -y update
218+
219+
# Install minimal runtime dependencies
220+
dnf -y install \
221+
alsa-lib \
222+
atk \
223+
bash \
224+
cups \
225+
gtk3 \
226+
mesa-libgbm \
227+
openssl \
228+
openssl-libs \
229+
python3
230+
231+
# Clean up package manager cache
232+
dnf clean all
233+
rm -rf /var/cache/dnf/* /tmp/* /var/tmp/*
234+
EOF
235+
167236
COPY --from=tsffs-base /workspace/projects /workspace/projects
168237
COPY --from=tsffs-base /workspace/simics /workspace/simics
169238
COPY --from=tsffs-base /root/.bashrc /root/.bashrc

0 commit comments

Comments
 (0)