Merge pull request #127 from adamantike/fix/copy-dependencies-from-stage

Reduce Docker image size by only copying pip installed dependencies
This commit is contained in:
Timothy Miller 2023-10-12 02:15:43 -04:00 committed by GitHub
commit 9a295bbf91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,12 +6,13 @@ FROM python:alpine AS base
FROM base AS dependencies FROM base AS dependencies
# install dependencies # install dependencies
COPY requirements.txt . COPY requirements.txt .
RUN pip install -r requirements.txt RUN pip install --user -r requirements.txt
# #
# ---- Release ---- # ---- Release ----
FROM dependencies AS release FROM base AS release
# copy project source file(s) # copy installed dependencies and project source file(s)
WORKDIR / WORKDIR /
COPY --from=dependencies /root/.local /root/.local
COPY cloudflare-ddns.py . COPY cloudflare-ddns.py .
CMD ["python", "-u", "/cloudflare-ddns.py", "--repeat"] CMD ["python", "-u", "/cloudflare-ddns.py", "--repeat"]