mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-02-17 07:03:58 +00:00
* Use multi-stage build to reduce image size * Add ARGS to be more flexible during image builds * Create user and use it instead of root * Don't update pip in container. The Python image should have a recent version
36 lines
589 B
Docker
36 lines
589 B
Docker
ARG BASE_IMAGE=python:3.9-slim
|
|
ARG USERNAME=parsedmarc
|
|
ARG USER_UID=1000
|
|
ARG USER_GID=$USER_UID
|
|
|
|
## build
|
|
|
|
FROM $BASE_IMAGE AS build
|
|
|
|
WORKDIR /app
|
|
|
|
RUN pip install hatch
|
|
|
|
COPY parsedmarc/ parsedmarc/
|
|
COPY README.md pyproject.toml ./
|
|
|
|
RUN hatch build
|
|
|
|
## image
|
|
|
|
FROM $BASE_IMAGE
|
|
ARG USERNAME
|
|
ARG USER_UID
|
|
ARG USER_GID
|
|
|
|
COPY --from=build /app/dist/*.whl /tmp/dist/
|
|
RUN set -ex; \
|
|
groupadd --gid ${USER_GID} ${USERNAME}; \
|
|
useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME}; \
|
|
pip install /tmp/dist/*.whl; \
|
|
rm -rf /tmp/dist
|
|
|
|
USER $USERNAME
|
|
|
|
ENTRYPOINT ["parsedmarc"]
|