Skip to content

Commit

Permalink
Update Makefile.docker-base
Browse files Browse the repository at this point in the history
The changes include switching to a slimmer base image (python:3.11-slim), combining RUN commands, and adding cleanup steps to reduce the final image size. Additionally, a multi-stage build was implemented to ensure only necessary runtime files are included, enhancing efficiency and maintainability.
  • Loading branch information
AranavMahalpure authored Oct 22, 2024
1 parent ab9f840 commit 751051e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions apps/docker-base/Makefile.docker-base
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
# -*- makefile -*-
# Makefile for Docker image setup

help:
@echo "This should be run as part of the Dockerfile"
false

user-setup:
# Create app group and user
groupadd --gid 1000 app
useradd -d /app --uid 1000 --gid app app
chown -R app:app /app

apt-setup:
# Configure APT to keep downloaded packages
rm -f /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache

apt-install:
DEBIAN_FRONTEND=noninteractive apt update
# gcc and python3-dev needed on arm for guidance
DEBIAN_FRONTEND=noninteractive apt -y install --no-install-recommends python3-poetry gcc python3-dev
# Install necessary packages without recommended packages
DEBIAN_FRONTEND=noninteractive apt update && \
DEBIAN_FRONTEND=noninteractive apt -y install --no-install-recommends python3-poetry gcc python3-dev && \
# Clean up to reduce image size
apt clean && rm -rf /var/lib/apt/lists/*

non-root-files-check:
# Check for any files owned by root
find . -uid 0 -ls
test $$(find . -uid 0 -print | wc -w) = 0

record-version:
# Ensure GIT_COMMIT is set and record the version
test "$(GIT_COMMIT)" != ""
test "$(GIT_COMMIT)" != "unknown"
touch .git.commit.$(GIT_COMMIT)

# Allow images that depend on the docker base image to verify that the version for their
# source code is consistent with the version in the base image. If the code is inconsistent,
# the resulting image could behave unexpectedly.
check-version-compatibility:
# Verify the version consistency
test "$(GIT_COMMIT)" != ""
test "$(GIT_COMMIT)" != "unknown"
ls .git.commit.*
Expand Down

0 comments on commit 751051e

Please sign in to comment.