-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): Add all-in-one Docker container for production deployment
- Loading branch information
Showing
6 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__pycache__ | ||
.env | ||
app/node_modules |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM node:14-alpine AS app | ||
|
||
COPY app /app | ||
WORKDIR /app | ||
RUN yarn | ||
ENV API_ROOT=/api | ||
RUN yarn build | ||
|
||
FROM python:3.9-slim | ||
|
||
RUN pip install pipenv gunicorn | ||
WORKDIR /usr/src/app | ||
COPY backend . | ||
RUN mkdir /data | ||
RUN pipenv install --deploy --system | ||
|
||
RUN apt update && apt install -y \ | ||
nginx-light \ | ||
supervisor \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=app /app/dist /var/www/html | ||
COPY docker / | ||
|
||
WORKDIR /usr/src/app/dpt_app | ||
RUN python manage.py collectstatic --no-input | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["/usr/bin/supervisord", "--nodaemon", "-c", "/etc/supervisor/supervisord.conf"] |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
|
||
root /var/www/html; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
location ~ ^/(api|admin) { | ||
proxy_pass http://127.0.0.1:8000; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /static { | ||
alias /usr/src/app/dpt_app/staticfiles; | ||
} | ||
|
||
location /media { | ||
alias /data/media; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[program:dpt-backend] | ||
command = /usr/src/app/dpt_app/run.sh | ||
directory = /usr/src/app/dpt_app | ||
|
||
[program:nginx] | ||
command = /usr/sbin/nginx -g 'daemon off;' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
./manage.py migrate | ||
gunicorn -b [::]:8000 dpt_app.wsgi:application |