Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cookiecutter flask
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Remy Mudingay
Cookiecutter flask
Commits
e85ce981
Commit
e85ce981
authored
5 years ago
by
James Curtin
Committed by
James Curtin
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Run docker container as non-root user
Closes #528
parent
4011fb1b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+4
-5
4 additions, 5 deletions
Dockerfile
{{cookiecutter.app_name}}/Dockerfile
+10
-5
10 additions, 5 deletions
{{cookiecutter.app_name}}/Dockerfile
with
14 additions
and
10 deletions
Dockerfile
+
4
−
5
View file @
e85ce981
FROM
python:3.7-alpine
RUN
apk update
\
&&
apk upgrade
\
&&
apk add
--no-cache
git
FROM
python:3.7-slim-buster
RUN
pip
install
\
cookiecutter
==
1.6.0
RUN
useradd
-m
sid
USER
sid
ENTRYPOINT
[ "python", "-m", "cookiecutter" ]
This diff is collapsed.
Click to expand it.
{{cookiecutter.app_name}}/Dockerfile
+
10
−
5
View file @
e85ce981
# ==================================== BASE ====================================
ARG
INSTALL_PYTHON_VERSION=${INSTALL_PYTHON_VERSION:-3.7}
FROM
python:${INSTALL_PYTHON_VERSION}-slim-
stretch
AS
base
FROM
python:${INSTALL_PYTHON_VERSION}-slim-
buster
AS
base
RUN
apt-get update
RUN
apt-get
install
-y
\
...
...
@@ -21,6 +21,11 @@ COPY requirements requirements
{%- endif %}
COPY
[ "assets", "package.json", "webpack.config.js", "./" ]
RUN
useradd
-m
sid
RUN
chown
-R
sid:sid /app
USER
sid
ENV
PATH="/home/sid/.local/bin:${PATH}"
RUN
npm
install
# ================================= DEVELOPMENT ================================
...
...
@@ -28,7 +33,7 @@ FROM base AS development
{%- if cookiecutter.use_pipenv == "yes" %}
RUN
pipenv
install
--dev
{%- else %}
RUN
pip
install
-r
requirements/dev.txt
RUN
pip
install
--user
-r
requirements/dev.txt
{%- endif %}
EXPOSE
2992
EXPOSE
5000
...
...
@@ -39,7 +44,7 @@ FROM base AS production
{%- if cookiecutter.use_pipenv == "yes" %}
RUN
pipenv
install
{%- else %}
RUN
pip
install
-r
requirements/prod.txt
RUN
pip
install
--user
-r
requirements/prod.txt
{%- endif %}
COPY
supervisord.conf /etc/supervisor/supervisord.conf
COPY
supervisord_programs /etc/supervisor/conf.d
...
...
@@ -50,8 +55,8 @@ CMD ["-c", "/etc/supervisor/supervisord.conf"]
# =================================== MANAGE ===================================
FROM
base
AS
manage
{%- if cookiecutter.use_pipenv == "yes" %}
COPY
--from=development /
root
/.local/share/virtualenvs/ /
root
/.local/share/virtualenvs/
COPY
--from=development /
sid
/.local/share/virtualenvs/ /
sid
/.local/share/virtualenvs/
{%- else %}
RUN
pip
install
-r
requirements/dev.txt
RUN
pip
install
--user
-r
requirements/dev.txt
{%- endif %}
ENTRYPOINT
[ {% if cookiecutter.use_pipenv == 'yes' %}"pipenv", "run", {% endif %}"flask" ]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment