diff options
author | Andrew Godwin | 2022-11-12 22:10:06 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-12 22:10:06 -0700 |
commit | 143a4a6e8c70557710d1b207a176f169d145ed1e (patch) | |
tree | 133454aa4da2b5614a33bc4a91d7b152f50eb40c /docker | |
parent | 878f56b411279cd9865a7ec05f1d14c9f70f6187 (diff) | |
download | takahe-143a4a6e8c70557710d1b207a176f169d145ed1e.tar.gz takahe-143a4a6e8c70557710d1b207a176f169d145ed1e.tar.bz2 takahe-143a4a6e8c70557710d1b207a176f169d145ed1e.zip |
Start some settings work
Diffstat (limited to 'docker')
-rw-r--r-- | docker/Dockerfile | 29 | ||||
-rw-r--r-- | docker/docker-compose.yml | 42 | ||||
-rw-r--r-- | docker/start.sh | 7 |
3 files changed, 78 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..14e033b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,29 @@ +# Build stage + +FROM python:3.11.0-buster as builder + +RUN mkdir -p /takahe +RUN python -m venv /takahe/.venv +RUN apt-get update && apt-get -y install libpq-dev python3-dev + +WORKDIR /takahe + +COPY requirements.txt requirements.txt + +RUN . /takahe/.venv/bin/activate \ + && pip install --upgrade pip \ + && pip install --upgrade -r requirements.txt + +# Final image stage + +FROM python:3.11.0-slim-buster + +RUN apt-get update && apt-get install -y libpq5 + +COPY --from=builder /takahe /takahe +COPY . /takahe + +WORKDIR /takahe +EXPOSE 8000 + +CMD ["/takahe/docker/start.sh"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..00463bf --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,42 @@ +version: "3" + +services: + db: + image: postgres:15-alpine + healthcheck: + test: ['CMD', 'pg_isready', '-U', 'postgres'] + volumes: + - dbdata:/var/lib/postgresql/data + networks: + - internal_network + restart: always + environment: + - "POSTGRES_DB=tahake" + - "POSTGRES_USER=postgres" + - "POSTGRES_PASSWORD=insecure_password" + + web: + build: . + image: tahake:latest + environment: + - "DJANGO_SETTINGS_MODULE=takahe.settings.production" + - "SECRET_KEY=insecure_secret" + - "POSTGRES_HOST=db" + - "POSTGRES_DB=tahake" + - "POSTGRES_USER=postgres" + - "POSTGRES_PASSWORD=insecure_password" + networks: + - external_network + - internal_network + restart: always + depends_on: + - db + ports: + - "8000:8000" + +networks: + internal_network: + external_network: + +volumes: + dbdata: diff --git a/docker/start.sh b/docker/start.sh new file mode 100644 index 0000000..99f1ed0 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +. /takahe/.venv/bin/activate + +python manage.py migrate + +exec gunicorn takahe.asgi:application -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000 |