diff --git a/README.md b/README.md index 37772faf..cdee87bd 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker-compose.postgres.yaml b/docker-compose.postgres.yaml new file mode 100644 index 00000000..c1f5e6a6 --- /dev/null +++ b/docker-compose.postgres.yaml @@ -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 diff --git a/compose.yaml b/docker-compose.sqlite.yaml similarity index 77% rename from compose.yaml rename to docker-compose.sqlite.yaml index a57c2338..701e418f 100644 --- a/compose.yaml +++ b/docker-compose.sqlite.yaml @@ -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 diff --git a/postgres.env b/postgres.env new file mode 100644 index 00000000..d53821d3 --- /dev/null +++ b/postgres.env @@ -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 \ No newline at end of file