Skip to content

@AkshataABhat: Dockerfile enhancement: multistage build #995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# * Install python3-venv for the built-in Python3 venv module (not installed by default).
# * Install gcloud CLI from Google Cloud's apt repository.

FROM debian:12
# Stage 1: Build
FROM debian:12 AS build
# Install packages used by the Experiment. Python and Git are required for the experiment.
# Curl, certs, and gnupg are required to install gcloud.
RUN apt-get update && \
Expand All @@ -32,27 +33,27 @@ RUN apt-get update && \
wget2 \
clang-format && \
python3 -m venv /venv

# Install gcloud cli.
RUN echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update -y && \
apt-get install google-cloud-cli -y
# Set timezone to Australia/Sydney.
ENV TZ='Australia/Sydney'



# Install Docker for OSS-Fuzz.
# Add Docker's official GPG key:
RUN apt-get install ca-certificates curl gnupg && \
install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/debian/gpg \
| gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null

RUN apt-get update && \
apt-get install -y \
docker-ce \
Expand All @@ -61,8 +62,17 @@ RUN apt-get update && \
docker-buildx-plugin \
docker-compose-plugin


COPY . /experiment
WORKDIR /experiment
RUN /venv/bin/pip install --disable-pip-version-check -r requirements.txt
ENTRYPOINT ["/venv/bin/python3", "./report/docker_run.py"]
RUN /venv/bin/pip install --disable-pip-version-check --default-timeout=100 -r requirements.txt

# Stage 2: Runtime
FROM debian:12
# Set timezone to Australia/Sydney.
ENV TZ='Australia/Sydney'

COPY --from=build /venv /venv
COPY --from=build /experiment /experiment
WORKDIR /experiment

ENTRYPOINT ["/venv/bin/python3", "./report/docker_run.py"]
Loading