feat: add a docker-compose.yml with included database for more convenient self-hosting

This commit is contained in:
rolv 2024-11-17 09:56:50 +00:00 committed by Hakan Ensari
parent ff867d6c35
commit 7b2fd751c7
2 changed files with 50 additions and 0 deletions

View File

@ -35,3 +35,11 @@ docker run -d -p 8080:8080 \
-e "DATABASE_URL=<postgres_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.

42
docker-compose.yml Normal file
View File

@ -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