Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kszkepzes-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
KSZK
DevTeam
kszkepzes
old
kszkepzes-backend
Commits
2969d637
Commit
2969d637
authored
5 years ago
by
Rafael László
Browse files
Options
Downloads
Patches
Plain Diff
better Dockerfile.prod
parent
fc65fd8f
No related branches found
No related tags found
1 merge request
!2
Dev
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Dockerfile.prod
+11
-55
11 additions, 55 deletions
Dockerfile.prod
with
11 additions
and
55 deletions
Dockerfile.prod
+
11
−
55
View file @
2969d637
###########
FROM python:3.8.1
# BUILDER #
###########
# pull official base image
FROM python:3.8.1 as builder
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONUNBUFFERED 1
ENV TZ Europe/Budapest
# install dependencies
ENV HOME /home/app
RUN apt-get -y update
ENV APP_HOME /home/app/kszkepzes-backend
RUN apt-get install -y python python-pip python-dev python-django-extensions postgresql-client netcat
RUN groupadd app && useradd -g app app && \
RUN apt-get -y update && apt-get -y autoremove
mkdir -p /home/app && mkdir $APP_HOME && \
mkdir $APP_HOME/staticfiles && mkdir $APP_HOME/mediafiles
# lint
RUN pip install --upgrade pip
RUN pip install flake8
COPY ./src /usr/src/app/
#RUN flake8 --max-line-length=125 --exclude=kszkepzes,migrations .
# install dependencies
COPY ./requirements/production.txt /usr/src/app/requirements.txt
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
#########
# FINAL #
#########
# pull official base image
FROM python:3.8.1
# create directory for the app user
RUN mkdir -p /home/app
# create the app user
RUN groupadd app && useradd -g app app
# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/kszkepzes-backend
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/staticfiles
RUN mkdir $APP_HOME/mediafiles
WORKDIR $APP_HOME
WORKDIR $APP_HOME
# install dependencies
COPY ./requirements/production.txt requirements.txt
RUN apt-get -y update && apt-get install netcat -y
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
# copy entrypoint-prod.sh
RUN apt-get -y update && apt-get install -y python python-pip python-dev python-django-extensions postgresql-client netcat
COPY ./src/entrypoint.prod.sh $APP_HOME
RUN pip install -r requirements.txt
# copy project
COPY ./src $APP_HOME
COPY ./src $APP_HOME
# chown all the files to the app user
RUN chown -R app:app $APP_HOME
RUN chown -R app:app $APP_HOME
# change to the app user
USER app
USER app
EXPOSE 8000
EXPOSE 8000
CMD ["gunicorn" "kszkepzes.wsgi:application" "--bind" "0.0.0.0:8000"]
CMD ["gunicorn" "kszkepzes.wsgi:application" "--bind" "0.0.0.0:8000"]
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