Skip to content

Commit

Permalink
Make docker image lighter
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Vanden Broeck committed Dec 19, 2024
1 parent 14f72ed commit 8eb7a0b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
FROM docker:24.0.8-dind

RUN apk add --no-cache python3 python3-dev py3-pip gcc jq \
git curl build-base autoconf automake py3-cryptography rsync \
linux-headers musl-dev libffi-dev openssl-dev openssh-client
FROM python:3.12-alpine AS builder

RUN python3 -m venv --upgrade-deps /opt/venv
RUN apk add --no-cache python3 python3-dev py3-pip gcc \
git curl build-base autoconf automake py3-cryptography \
linux-headers musl-dev libffi-dev openssl-dev

COPY . /usr/local/src/ansible_collection_helper
RUN /opt/venv/bin/pip install --no-cache-dir /usr/local/src/ansible_collection_helper &&\
rm -rf /usr/local/src/ansible_collection_helper
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /build/wheels /usr/local/src/ansible_collection_helper

FROM docker:24.0.8-dind
RUN apk add --no-cache python3 py3-pip jq py3-cryptography rsync openssh-client
COPY --from=builder /build/wheels /wheels
RUN python3 -m venv /opt/venv/
RUN /opt/venv/bin/pip install --no-cache-dir /wheels/*

0 comments on commit 8eb7a0b

Please sign in to comment.