-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance Dockerfile: switch to nonroot user and improve labels
- Loading branch information
Showing
1 changed file
with
13 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
@@ -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"] |