-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
46 lines (32 loc) · 1.23 KB
/
Dockerfile
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
44
45
46
FROM python:3.6
# Install curl, node, & yarn
RUN apt-get -y install curl \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash \
&& apt-get install nodejs \
&& curl -o- -L https://yarnpkg.com/install.sh | bash
WORKDIR /app/backend
# Install Python dependencies
COPY ./backend/requirements.txt /app/backend/
RUN pip3 install --upgrade pip -r requirements.txt
# Install JS dependencies
WORKDIR /app/frontend
COPY ./frontend/package.json ./frontend/yarn.lock /app/frontend/
RUN $HOME/.yarn/bin/yarn install
# Add the rest of the code
COPY . /app/
# Build static files
RUN $HOME/.yarn/bin/yarn build
# Have to move all static files other than index.html to root/
# for whitenoise middleware
WORKDIR /app/frontend/build
RUN mkdir root && mv *.ico *.js *.json root
# Collect static files
RUN mkdir /app/backend/staticfiles
WORKDIR /app
# SECRET_KEY is only included here to avoid raising an error when generating static files.
# Be sure to add a real SECRET_KEY config variable in Heroku.
RUN DJANGO_SETTINGS_MODULE=backend.settings.production \
SECRET_KEY=somethingsupersecret \
python3 backend/manage.py collectstatic --noinput
EXPOSE $PORT
CMD python3 backend/manage.py runserver 0.0.0.0:$PORT