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

Removed root user and added "app" user #9

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
32 changes: 24 additions & 8 deletions template/python3-debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
FROM openfaas/classic-watchdog:0.13.4 as watchdog

FROM python:3

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

RUN useradd -m app

WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN chown -R app /home/app && \
mkdir -p /home/app/python && chown -R app /home/app

USER app
ENV PATH=$PATH:/home/app/.local/bin:/home/app/python/bin/
ENV PYTHONPATH=$PYTHONPATH:/home/app/python

RUN pip install -r requirements.txt --target=/home/app/python

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 -r requirements.txt --target=/home/app/python

WORKDIR /home/app/

WORKDIR /root/
USER root
COPY function function
RUN chown -R app:app ./ && \
chmod -R 777 /home/app/python

WORKDIR /root/
USER app

ENV fprocess="python3 index.py"

Expand Down