diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..5944983 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,37 @@ +FROM python:3.10.9-slim-bullseye + +LABEL maintainer "Ameya Shenoy " + +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 + diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..6717dc7 --- /dev/null +++ b/docker-compose.prod.yml @@ -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: + diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..11daf19 --- /dev/null +++ b/web/Dockerfile @@ -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 +