Run container as non-root user (#11)
Build and publish container / build (push) Successful in 5m59s
Build and publish container / build (push) Successful in 5m59s
Adds a dedicated non-root user and switches to it before CMD. Verified the container runs as a non-root uid. Closes #7 Reviewed-on: #11 Co-authored-by: Lyra Thorpe <iam@emmathe.dev> Co-committed-by: Lyra Thorpe <iam@emmathe.dev>
This commit was merged in pull request #11.
This commit is contained in:
+6
-1
@@ -3,11 +3,16 @@ FROM python:3.12-slim
|
||||
WORKDIR /app
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Create a dedicated non-root user and group to run the proxy.
|
||||
RUN groupadd --system appuser && useradd --system --gid appuser appuser
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY proxy_server.py ./
|
||||
COPY --chown=appuser:appuser proxy_server.py ./
|
||||
|
||||
EXPOSE 110 25
|
||||
|
||||
USER appuser
|
||||
|
||||
CMD ["python", "proxy_server.py"]
|
||||
|
||||
Reference in New Issue
Block a user