Created
February 7, 2021 19:48
-
-
Save PatrickKalkman/b7fabb5dfea9f09200c2e34aa792bd6b to your computer and use it in GitHub Desktop.
Add non root user to docker file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM python:3.8.7-alpine | |
| RUN pip install --upgrade pip | |
| RUN pip install pipenv | |
| RUN adduser -D python | |
| # Create the work dir and set permissions as WORKDIR set the permissions as root | |
| RUN mkdir /home/python/app/ && chown -R python:python /home/python/app | |
| WORKDIR /home/python/app | |
| USER python | |
| RUN pip install --user pipenv | |
| ENV PATH="/home/worker/.local/bin:${PATH}" | |
| COPY --chown=python:python Pipfile Pipfile | |
| RUN pipenv lock -r > requirements.txt | |
| RUN pip install --user -r requirements.txt | |
| COPY --chown=python:python . . | |
| CMD ["python", "main.py"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment