Skip to content
This repository has been archived by the owner on Mar 7, 2020. It is now read-only.

Modified Dockerfile to run as non-root #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 21 additions & 8 deletions template/python3-debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,38 @@ FROM python:3

RUN curl -sSL https://github.com/openfaas/faas/releases/download/0.9.6/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog
WORKDIR /root/

# Add non root user
RUN adduser app --system --group

WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
RUN pip install -r requirements.txt

RUN chown -R app /home/app

USER app
ENV PATH=$PATH:/home/app/.local/bin
RUN pip install --user -r requirements.txt

RUN mkdir -p function
RUN touch ./function/__init__.py
WORKDIR /root/function/

WORKDIR /home/app/function/
COPY function/requirements.txt .
RUN pip install -r requirements.txt
RUN pip install --user -r requirements.txt

WORKDIR /root/
COPY function function
WORKDIR /home/app

WORKDIR /root/
USER root
COPY function function
RUN chown -R app:app ./
USER app

ENV fprocess="python3 index.py"
EXPOSE 8080

HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1
HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1

CMD ["fwatchdog"]