feat: dockerize for prod
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
parent
ae57e86d23
commit
ebc2f4f8c5
3 changed files with 87 additions and 0 deletions
37
backend/Dockerfile
Normal file
37
backend/Dockerfile
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
FROM python:3.10.9-slim-bullseye
|
||||||
|
|
||||||
|
LABEL maintainer "Ameya Shenoy <shenoy.ameya@gmail.com>"
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
|
||||||
|
|
||||||
|
ENV GUNICORN_VERSION=20.1.0
|
||||||
|
ARG APP_USER=app
|
||||||
|
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
|
COPY requirements.txt /
|
||||||
|
|
||||||
|
RUN set -ex \
|
||||||
|
&& pip install --no-cache-dir -r /requirements.txt \
|
||||||
|
&& pip install --no-cache-dir gunicorn==$GUNICORN_VERSION \
|
||||||
|
&& apk del .build-deps \
|
||||||
|
&& addgroup -S ${APP_USER} \
|
||||||
|
&& adduser -S ${APP_USER} -G ${APP_USER} \
|
||||||
|
&& mkdir -p /code/static \
|
||||||
|
&& mkdir -p /code/media \
|
||||||
|
&& mkdir -p /code/static_cdn \
|
||||||
|
&& mkdir -p /code/media_cdn \
|
||||||
|
&& chown -R ${APP_USER}:${APP_USER} /code/
|
||||||
|
|
||||||
|
COPY . /code
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
|
RUN set -ex \
|
||||||
|
&& python manage.py collectstatic --no-input
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
USER ${APP_USER}:${APP_USER}
|
||||||
|
ENTRYPOINT gunicorn --workers 2 --bind 0.0.0.0 backend.wsgi
|
||||||
|
|
||||||
39
docker-compose.prod.yml
Normal file
39
docker-compose.prod.yml
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
image: foldbank-web-prod
|
||||||
|
build:
|
||||||
|
context: ./web
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
backend:
|
||||||
|
image: foldbank-backend-prod
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- prod.env
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
- postgres-db
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7.0.0-alpine3.16
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
postgres-db:
|
||||||
|
image: postgres:14.3-alpine3.16
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- postgres-data:/var/lib/postgresql/data/pgdata
|
||||||
|
env_file:
|
||||||
|
- prod.env
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres-data:
|
||||||
|
|
||||||
11
web/Dockerfile
Normal file
11
web/Dockerfile
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
FROM node:16.19.1-alpine3.17
|
||||||
|
|
||||||
|
COPY web /code
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
|
RUN set -ex \
|
||||||
|
&& npm i \
|
||||||
|
&& npm run build
|
||||||
|
|
||||||
|
ENTRYPOINT npm start
|
||||||
|
|
||||||
Loading…
Reference in a new issue