From a835f4552516b90f8ebba51de296d54a5914a8a2 Mon Sep 17 00:00:00 2001 From: lfjnascimento Date: Thu, 27 Jun 2024 13:40:32 -0300 Subject: [PATCH] feat: add docker-compose.yml creating proxy, backend and db services Closes: #14 --- README.md | 11 +++++++- docker-compose.yml | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index 7a13b28..4f2b6fb 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,13 @@ What we have as a repository is a monorepo containing the *dashboard* (the web a A web app built with [React](https://react.dev/) + [Typescript](https://www.typescriptlang.org/), to see more information check the dashboard [README](dashboard/README.md). ### Backend -A Python http server built with [Django](https://www.djangoproject.com/) + [DRF](https://www.django-rest-framework.org/), to see more information check the backend [README](/backend/README.md). \ No newline at end of file +A Python http server built with [Django](https://www.djangoproject.com/) + [DRF](https://www.django-rest-framework.org/), to see more information check the backend [README](/backend/README.md). + + +# Docker compose + +```bash +mkdir -p backend/runtime/secrets +uuidgen > backend/runtime/secrets/postgres_password_secret +docker-compose up -d +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fae52eb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,63 @@ +volumes: + db-data: + runtime-data: + +networks: + public: + private: + +secrets: + postgres_password_secret: + file: ./backend/runtime/secrets/postgres_password_secret + +services: + db: + image: postgres:16.3-alpine + networks: + - private + environment: + - POSTGRES_USER=kernelci + - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password_secret + - PGDATA=/var/run/postgresql/data + volumes: + - db-data:/var/run/postgresql/data + ports: + - target: 5432 + published: 5432 + protocol: tcp + mode: host + secrets: + - postgres_password_secret + + backend: + build: ./backend + restart: always + networks: + - private + - public + ports: + - target: 8000 + published: 8000 + protocol: tcp + mode: host + secrets: + - postgres_password_secret + environment: + - 'ALLOWED_HOSTS=["backend"]' + - DB_DEFAULT_PASSWORD_FILE=/run/secrets/postgres_password_secret + - DB_DEFAULT_HOST=db + + proxy: + build: ./proxy + restart: always + depends_on: + - backend + networks: + - public + ports: + - target: 80 + published: 80 + protocol: tcp + mode: host + environment: + - PROXY_TARGET=http://backend:8000