Skip to content

Commit

Permalink
Enhance Dockerfile: switch to nonroot user and improve labels
Browse files Browse the repository at this point in the history
  • Loading branch information
otherguy committed Sep 30, 2024
1 parent 8051ed8 commit c951108
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
FROM python:3.12.6-slim


# Create nonroot user and group
RUN useradd --system --user-group --uid 1001 --home-dir /workdir nonroot

# Switch to nonroot user
USER nonroot:nonroot

# Set working directory
WORKDIR /workdir

# Install
COPY requirements.txt .
COPY --chown=nonroot:nonroot requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
&& rm requirements.txt

Expand All @@ -21,11 +29,10 @@ LABEL org.opencontainers.image.created="${BUILD_DATE}"
LABEL org.opencontainers.image.revision="${VCS_REF}"

# Maintainer
LABEL maintainer 'otherguy <[email protected]>'
LABEL maintainer="otherguy <[email protected]>"

# Whalebrew
LABEL io.whalebrew.name 'yamlfix'
LABEL io.whalebrew.config.keep_container_user 'false'
LABEL io.whalebrew.config.working_dir '$PWD'
LABEL io.whalebrew.name="yamlfix"
LABEL io.whalebrew.config.keep_container_user="false"

ENTRYPOINT ["/usr/local/bin/yamlfix"]
ENTRYPOINT ["/workdir/.local/bin/yamlfix"]

0 comments on commit c951108

Please sign in to comment.