diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..5c9aa80 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.11.4-slim-bullseye + +WORKDIR /fastapi_app/backend + +COPY ./backend/requirements.txt /fastapi_app/backend + +RUN pip install --no-cache-dir --upgrade pip + +RUN pip install --no-cache-dir -r /fastapi_app/backend/requirements.txt + +COPY ./backend /fastapi_app/backend + +RUN chmod a+x ./*.sh \ No newline at end of file diff --git a/backend/docker-launch.sh b/backend/docker-launch.sh new file mode 100644 index 0000000..32e69bf --- /dev/null +++ b/backend/docker-launch.sh @@ -0,0 +1,4 @@ +#!/bin/bash +alembic upgrade head +cd src || exit +gunicorn main:app --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind=0.0.0.0:"$BACK_APP_PORT" --timeout 300 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 45feb85..0379069 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,17 @@ version: "3.8" services: + backend: + container_name: fastapi_app + build: + context: . + dockerfile: ./backend/Dockerfile + env_file: + - .env + command: [ "sh", "/fastapi_app/backend/docker-launch.sh" ] + ports: + - "${BACK_APP_PORT}:${BACK_APP_PORT}" + restart: unless-stopped + db: container_name: db_app image: postgres:15