Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postgres docker-compose file #308

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,20 @@ or use docker compose
mkdir -p /opt/workout-tracker
cd /opt/workout-tracker

# Download the compose.yaml
curl https://raw.githubusercontent.com/jovandeginste/workout-tracker/master/compose.yaml --output compose.yaml
# Download the docker compose file
## For sqlite as database:
curl https://raw.githubusercontent.com/jovandeginste/workout-tracker/master/docker-compose.sqlite.yaml --output docker-compose.yaml

## For postgres as database:
curl https://raw.githubusercontent.com/jovandeginste/workout-tracker/master/docker-compose.postgres.yaml --output docker-compose.yaml
curl https://raw.githubusercontent.com/jovandeginste/workout-tracker/master/postgres.env --output postgres.env

# Start the server
docker compose up -d
```

> **_NOTE:_** If using postgres, configure the parameters in `postgres.env`.

### Natively

Download a
Expand Down
37 changes: 37 additions & 0 deletions docker-compose.postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
services:
workout-tracker:
image: ghcr.io/jovandeginste/workout-tracker:master
container_name: wt-app
restart: unless-stopped
ports:
# Host Port:Container Port
- 8080:8080
networks:
- workout-tracker
env_file:
- postgres.env
depends_on:
db:
condition: service_healthy

db:
image: postgres:16-alpine
container_name: wt-db
restart: unless-stopped
shm_size: 128mb
volumes:
# Store database files in a local directory.
- ./data:/var/lib/postgresql/data
networks:
- workout-tracker
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
interval: 5s
timeout: 5s
retries: 5
env_file:
- postgres.env

networks:
workout-tracker:
external: false
3 changes: 2 additions & 1 deletion compose.yaml → docker-compose.sqlite.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
version: "3.8"
services:
workout-tracker:
image: ghcr.io/jovandeginste/workout-tracker:master
container_name: wt-app
restart: unless-stopped
ports:
# Host Port:Container Port
- 8080:8080
volumes:
# Mount local directory for sqlite database
- ./data:/data
environment:
- WT_JWT_ENCRYPTION_KEY=my-secret-key
20 changes: 20 additions & 0 deletions postgres.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Change these parameters to your needs
TZ=Europe/Vienna
POSTGRES_USER=wt
POSTGRES_PASSWORD=change-me
POSTGRES_DB=wt

## Additional (optional) parameters
# - WT_BIND=[::]:8080
# - WT_LOGGING=true
# - WT_DEBUG=true
# - WT_REGISTRATION_DISABLED=true
# - WT_SOCIALS_DISABLED=true
# - WT_REGISTRATION_DISABLED=true
# - WT_SOCIALS_DISABLED=true
# - WT_JWT_ENCRYPTION_KEY=my-secret-key

## Only change these parameters if you know what you are doing
PGUSER=$POSTGRES_USER
WT_DATABASE_DRIVER=postgres
WT_DSN=host=db user=$POSTGRES_USER password=$POSTGRES_PASSWORD dbname=$POSTGRES_DB port=5432 sslmode=disable TimeZone=$TZ
Loading