From 7b2fd751c787d5ddf3104c68e5aa26fc5a63878f Mon Sep 17 00:00:00 2001 From: rolv Date: Sun, 17 Nov 2024 09:56:50 +0000 Subject: [PATCH] feat: add a `docker-compose.yml` with included database for more convenient self-hosting --- README.md | 8 ++++++++ docker-compose.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index e9154a4..c283a23 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,11 @@ docker run -d -p 8080:8080 \ -e "DATABASE_URL=" \ --name frankfurter hakanensari/frankfurter ``` + +Alternatively, copy the [docker-compose.yml](./docker-compose.yml) file to your system, and in the same directory run: + +```bash +docker compose up --wait +``` + +This will also setup and host the PostgreSQL for Frankfurter. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d651230 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +version: "3" +services: + db: + image: postgres:15 + container_name: frankfurter-db + environment: + - PGUSER=postgres + - POSTGRES_PASSWORD=password + volumes: + - ./api_data:/var/lib/postgresql/data + ports: + - 5432:5432 + networks: + - postgres-db-network + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 1s + timeout: 5s + retries: 10 + + api: + image: hakanensari/frankfurter + container_name: frankfurter-api + restart: unless-stopped + ports: + - "8080:8080" + environment: + DATABASE_URL: postgresql://postgres:password@db:5432/postgres + depends_on: + db: + condition: service_healthy + networks: + - postgres-db-network + healthcheck: + test: curl --fail http://localhost:8080 || exit 1 + interval: 1s + timeout: 5s + retries: 10 + +networks: + postgres-db-network: + driver: bridge