Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM alpine:latest

ARG USER=notroot
ARG GROUP=notroot
ARG USER=nonroot
ARG GROUP=nonroot
ARG UID=1000
ARG GID=1000

COPY requirements.txt /tmp/requirements.txt
COPY ./entrypoint.sh /usr/bin/entrypoint.sh
RUN set -xe && \
echo $(echo BUILD_TIME_ALPINE_VERSION: && /bin/cat /etc/alpine-release) && \
apk upgrade --no-cache && \
Expand All @@ -15,13 +14,11 @@ RUN set -xe && \
py3-pip && \
pip install -r /tmp/requirements.txt && \
addgroup -g ${GID} -S ${GROUP} && \
adduser -u ${UID} -S -D ${USER} ${GROUP} && \
chmod a+x /usr/bin/entrypoint.sh && \
mkdir /app && chown ${USER} /app


adduser -u ${UID} -S -D ${USER} ${GROUP}
COPY --chown=${USER} k8sci/ /app/k8sci/
WORKDIR /app
USER ${USER}
ENV PYTHONUNBUFFERED=TRUE

ENTRYPOINT /usr/bin/entrypoint.sh
ENTRYPOINT echo $(echo ALPINE_VERSION: && /bin/cat /etc/alpine-release) && \
gunicorn --bind 0.0.0.0:5000 --enable-stdio-inheritance --error-logfile "-" k8sci.wsgi:app
15 changes: 15 additions & 0 deletions Dockerfile_distroless
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.7-slim AS build
COPY requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt

### INFO:
# What is distroless: https://medium.com/better-programming/how-to-harden-your-containers-with-distroless-docker-images-c2abd7c71fdb
# Google Base Images: https://github.com/GoogleContainerTools/distroless/
FROM gcr.io/distroless/python3-debian10
COPY --chown=nonroot k8sci/ /app/k8sci/
COPY --from=build --chown=nonroot /usr/local/bin/gunicorn /app/gunicorn
COPY --from=build --chown=nonroot /usr/local/lib/python3.7/site-packages /usr/local/lib/python3.7/site-packages
USER nonroot
WORKDIR /app
ENV PYTHONPATH=/usr/local/lib/python3.7/site-packages PYTHONUNBUFFERED=TRUE
CMD ["gunicorn","--bind","0.0.0.0:5000","--enable-stdio-inheritance","--error-logfile","-","k8sci.wsgi:app"]
9 changes: 0 additions & 9 deletions entrypoint.sh

This file was deleted.