Skip to content

Instantly share code, notes, and snippets.

@rameshkrishna
Created February 14, 2022 02:48
Show Gist options
  • Save rameshkrishna/ffe3ffd7db0885c71f57eb0257b67679 to your computer and use it in GitHub Desktop.
Save rameshkrishna/ffe3ffd7db0885c71f57eb0257b67679 to your computer and use it in GitHub Desktop.
openfass-python-flask
FROM openfaas/of-watchdog:0.7.7 as watchdog
FROM python:3.7-slim-buster
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog
RUN apt-get -qy update
# Add non root user
RUN addgroup --system app && adduser app --system --ingroup app
RUN chown app /home/app
USER app
ENV PATH=$PATH:/home/app/.local/bin
WORKDIR /home/app/
COPY p.py .
COPY requirements.txt .
USER root
USER root
RUN mkdir -p /var/openfaas/
COPY secrets /var/openfaas/secrets
RUN pip install -r requirements.txt
# Build the function directory and install any user-specified components
USER app
#install function code
USER root
RUN chown -R app:app ../
WORKDIR /home/app/
#configure WSGI server and healthcheck
USER app
ENV fprocess="python p.py"
ENV cgi_headers="true"
ENV mode="http"
ENV upstream_url="http://127.0.0.1:5000"
HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1
CMD ["fwatchdog"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment