Skip to content

Commit

Permalink
Merge pull request #3 from devzero-inc/debo/img-size-optim
Browse files Browse the repository at this point in the history
optimizing image sizes
  • Loading branch information
dray92 authored Jan 7, 2025
2 parents a8bf922 + 40e6a3b commit 9b44c97
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 55 deletions.
53 changes: 25 additions & 28 deletions images/ubuntu/dockerfiles/Dockerfile.22.04
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ COPY images/ubuntu/scripts/docs-gen ${IMAGE_FOLDER}/docs-gen/
COPY helpers/software-report-base ${IMAGE_FOLDER}/docs-gen/
COPY images/ubuntu/toolsets/toolset-2204.json ${INSTALLER_SCRIPT_FOLDER}/toolset.json

# Configure machine instance
COPY images/ubuntu/assets/ubuntu2204.conf /tmp/
RUN mkdir -p /etc/vsts \
&& cp /tmp/ubuntu2204.conf /etc/vsts/machine_instance.conf

# ---------------------------------- START: CUSTOM ----------------------------------
## add all the systemd etc bits to make things work well in the dzboot world
## TODO: add dzboot at the end based on existing runner image
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y \
&& apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:git-core/ppa \
Expand Down Expand Up @@ -63,7 +67,7 @@ RUN mkdir -p /etc/cloud/templates/
### how the scripts are executed, the env var might not be set as we expect,
### or might not persist between layers (this is being a bit defensive to get
### it to work reliably)
ARG AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
ENV AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
# ---------------------------------- END: CUSTOM ----------------------------------

# Configure initial setup
Expand All @@ -88,6 +92,11 @@ RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-apt-vital.sh \
RUN pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-PowerShellModules.ps1 \
&& pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-PowerShellAzModules.ps1

## docker daemon won't/can't be running, hence we can't pull images - used in install-docker.sh
ENV DOCKERHUB_PULL_IMAGES=no
## needed for install-pipx-packages.sh
ENV PATH="$PATH:/opt/pipx_bin:/root/.local/bin"

# Install all tools
RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-actions-cache.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-runner-package.sh && \
Expand Down Expand Up @@ -148,36 +157,24 @@ RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-actions-cache.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-android-sdk.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-pypy.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-python.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-zstd.sh
bash ${INSTALLER_SCRIPT_FOLDER}/install-zstd.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-docker.sh && \
pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-Toolset.ps1 && \
pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Configure-Toolset.ps1 && \

## docker daemon won't/can't be running, hence we can't pull images
ARG DOCKERHUB_PULL_IMAGES=no
RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-docker.sh
# Install additional packages
bash ${INSTALLER_SCRIPT_FOLDER}/install-pipx-packages.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-homebrew.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/configure-snap.sh && \

# Configure toolset
RUN pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-Toolset.ps1 \
&& pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Configure-Toolset.ps1
# Cleanup and system configuration
bash ${INSTALLER_SCRIPT_FOLDER}/cleanup.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/configure-system.sh && \

# Install additional packages
ENV PATH="$PATH:/opt/pipx_bin:/root/.local/bin"
RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-pipx-packages.sh \
&& bash ${INSTALLER_SCRIPT_FOLDER}/install-homebrew.sh \
&& bash ${INSTALLER_SCRIPT_FOLDER}/configure-snap.sh

# Cleanup and system configuration
RUN bash ${INSTALLER_SCRIPT_FOLDER}/cleanup.sh \
&& bash ${INSTALLER_SCRIPT_FOLDER}/configure-system.sh
# Final cleanup
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Generate reports
# RUN pwsh -File ${IMAGE_FOLDER}/SoftwareReport/Generate-SoftwareReport.ps1 -OutputDirectory ${IMAGE_FOLDER} \
# && pwsh -File ${IMAGE_FOLDER}/tests/RunAll-Tests.ps1 -OutputDirectory ${IMAGE_FOLDER}

# Configure machine instance
COPY images/ubuntu/assets/ubuntu2204.conf /tmp/
RUN mkdir -p /etc/vsts \
&& cp /tmp/ubuntu2204.conf /etc/vsts/machine_instance.conf

# Final cleanup
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*

50 changes: 23 additions & 27 deletions images/ubuntu/dockerfiles/Dockerfile.24.04
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ COPY images/ubuntu/scripts/docs-gen ${IMAGE_FOLDER}/docs-gen/
COPY helpers/software-report-base ${IMAGE_FOLDER}/docs-gen/
COPY images/ubuntu/toolsets/toolset-2404.json ${INSTALLER_SCRIPT_FOLDER}/toolset.json

ENV DEBIAN_FRONTEND=noninteractive

# ---------------------------------- START: CUSTOM ----------------------------------
RUN apt-get update -y \
&& apt-get install -y software-properties-common \
Expand Down Expand Up @@ -56,7 +54,7 @@ RUN apt-get update -y \

RUN mkdir -p /etc/cloud/templates/

ARG AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
ENV AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache

## issue not fixed upstream https://github.com/actions/runner-images/issues/11028
## there's no netcat in 24.04 but the script tries to install that
Expand Down Expand Up @@ -90,6 +88,13 @@ RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-apt-vital.sh \
RUN pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-PowerShellModules.ps1 \
&& pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-PowerShellAzModules.ps1

## docker daemon won't/can't be running, hence we can't pull images - used in install-docker.sh
ENV DOCKERHUB_PULL_IMAGES=no
## needed for install-pipx-packages.sh
ENV PATH="$PATH:/opt/pipx_bin:/root/.local/bin"
## needed for install-homebrew.sh
ENV NONINTERACTIVE=1

# Install all tools
RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-actions-cache.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-runner-package.sh && \
Expand Down Expand Up @@ -139,35 +144,26 @@ RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-actions-cache.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-android-sdk.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-pypy.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-python.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-zstd.sh
bash ${INSTALLER_SCRIPT_FOLDER}/install-zstd.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-docker.sh && \

ARG DOCKERHUB_PULL_IMAGES=no
RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-docker.sh
# Configure toolset
pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-Toolset.ps1 && \
pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Configure-Toolset.ps1 && \

# Configure toolset
RUN pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Install-Toolset.ps1 \
&& pwsh -f ${INSTALLER_SCRIPT_FOLDER}/Configure-Toolset.ps1
# Install additional packages
bash ${INSTALLER_SCRIPT_FOLDER}/install-pipx-packages.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/install-homebrew.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/configure-snap.sh && \

# Install additional packages (env vars for pipx and brew)
ENV PATH="$PATH:/opt/pipx_bin:/root/.local/bin"
ENV NONINTERACTIVE=1
RUN bash ${INSTALLER_SCRIPT_FOLDER}/install-pipx-packages.sh \
&& bash ${INSTALLER_SCRIPT_FOLDER}/install-homebrew.sh \
&& bash ${INSTALLER_SCRIPT_FOLDER}/configure-snap.sh
# Cleanup and system configuration
bash ${INSTALLER_SCRIPT_FOLDER}/cleanup.sh && \
bash ${INSTALLER_SCRIPT_FOLDER}/configure-system.sh && \

# Cleanup and system configuration
RUN bash ${INSTALLER_SCRIPT_FOLDER}/cleanup.sh \
&& bash ${INSTALLER_SCRIPT_FOLDER}/configure-system.sh
# Final cleanup
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Generate reports
# RUN pwsh -File ${IMAGE_FOLDER}/SoftwareReport/Generate-SoftwareReport.ps1 -OutputDirectory ${IMAGE_FOLDER} \
# && pwsh -File ${IMAGE_FOLDER}/tests/RunAll-Tests.ps1 -OutputDirectory ${IMAGE_FOLDER}

# Configure machine instance
# COPY images/ubuntu/assets/ubuntu2204.conf /tmp/
# RUN mkdir -p /etc/vsts \
# && cp /tmp/ubuntu2204.conf /etc/vsts/machine_instance.conf

# Final cleanup
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*

0 comments on commit 9b44c97

Please # to comment.