-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile.railway
43 lines (32 loc) · 1.04 KB
/
Dockerfile.railway
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Base image
FROM python:3.10.12-slim-buster
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# create directory for the app user
RUN mkdir -p /home/app
# don't run as root therefore create non-root user
RUN groupadd --gid 1001 app && \
useradd --uid 1001 --gid app --home /home/app app
# install pipenv
RUN pip install pipenv
# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/website
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/staticfiles
RUN mkdir $APP_HOME/mediafiles
WORKDIR $APP_HOME
# installing dependencies
COPY Pipfile Pipfile.lock $APP_HOME
# install dependencies
RUN pipenv install --system
# copy project files and directories
COPY . $APP_HOME
# chown all the files to the app user
RUN chown -R app:app $APP_HOME
# change to the app user
USER app
# Port where the Django app runs
EXPOSE 8000
# Populate database and start server
CMD python3 manage.py migrate; python3 manage.py collectstatic --no-input; python3 manage.py loaddata website/fixtures/initial.json; gunicorn mywebsite.wsgi --bind 0.0.0.0:8000