Browse Source

Feature/modernize docker compose files (#4101)

* Modernize docker compose files

* Update changelog
pull/4154/head^2
Lennart Goedhart 3 weeks ago
committed by GitHub
parent
commit
aca4c3d46d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      .env.example
  2. 4
      CHANGELOG.md
  3. 2
      DEVELOPMENT.md
  4. 22
      README.md
  5. 49
      docker/docker-compose.build.yml
  6. 17
      docker/docker-compose.dev.yml
  7. 20
      docker/docker-compose.yml

4
.env.example

@ -1,7 +1,7 @@
COMPOSE_PROJECT_NAME=ghostfolio COMPOSE_PROJECT_NAME=ghostfolio
# CACHE # CACHE
REDIS_HOST=localhost REDIS_HOST=redis
REDIS_PORT=6379 REDIS_PORT=6379
REDIS_PASSWORD=<INSERT_REDIS_PASSWORD> REDIS_PASSWORD=<INSERT_REDIS_PASSWORD>
@ -12,5 +12,5 @@ POSTGRES_PASSWORD=<INSERT_POSTGRES_PASSWORD>
# VARIOUS # VARIOUS
ACCESS_TOKEN_SALT=<INSERT_RANDOM_STRING> ACCESS_TOKEN_SALT=<INSERT_RANDOM_STRING>
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer
JWT_SECRET_KEY=<INSERT_RANDOM_STRING> JWT_SECRET_KEY=<INSERT_RANDOM_STRING>

4
CHANGELOG.md

@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Changed the `REDIS_HOST` from `localhost` to `redis` in `.env.example`
- Changed the _Postgres_ host from `localhost` to `postgres` in `.env.example`
- Changed the _Postgres_ image from `postgres:15` to `postgres:15-alpine` in the `docker-compose` files
- Introduced `extends` in the `docker-compose` files
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
## 2.132.0 - 2024-12-30 ## 2.132.0 - 2024-12-30

2
DEVELOPMENT.md

@ -12,7 +12,7 @@
### Setup ### Setup
1. Run `npm install` 1. Run `npm install`
1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io) 1. Run `docker compose -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)
1. Run `npm run database:setup` to initialize the database schema 1. Run `npm run database:setup` to initialize the database schema
1. Start the [server](#start-server) and the [client](#start-client) 1. Start the [server](#start-server) and the [client](#start-client)
1. Open https://localhost:4200/en in your browser 1. Open https://localhost:4200/en in your browser

22
README.md

@ -118,7 +118,7 @@ We provide official container images hosted on [Docker Hub](https://hub.docker.c
Run the following command to start the Docker images from [Docker Hub](https://hub.docker.com/r/ghostfolio/ghostfolio): Run the following command to start the Docker images from [Docker Hub](https://hub.docker.com/r/ghostfolio/ghostfolio):
```bash ```bash
docker compose --env-file ./.env -f docker/docker-compose.yml up -d docker compose -f docker/docker-compose.yml up -d
``` ```
#### b. Build and run environment #### b. Build and run environment
@ -126,8 +126,8 @@ docker compose --env-file ./.env -f docker/docker-compose.yml up -d
Run the following commands to build and start the Docker images: Run the following commands to build and start the Docker images:
```bash ```bash
docker compose --env-file ./.env -f docker/docker-compose.build.yml build docker compose -f docker/docker-compose.build.yml build
docker compose --env-file ./.env -f docker/docker-compose.build.yml up -d docker compose -f docker/docker-compose.build.yml up -d
``` ```
#### Setup #### Setup
@ -137,9 +137,19 @@ docker compose --env-file ./.env -f docker/docker-compose.build.yml up -d
#### Upgrade Version #### Upgrade Version
1. Increase the version of the `ghostfolio/ghostfolio` Docker image in `docker/docker-compose.yml` 1. Update the _Ghostfolio_ Docker image
1. Run the following command to start the new Docker image: `docker compose --env-file ./.env -f docker/docker-compose.yml up -d`
At each start, the container will automatically apply the database schema migrations if needed. - Increase the version of the `ghostfolio/ghostfolio` Docker image in `docker/docker-compose.yml`
- Run the following command if `ghostfolio:latest` is set:
```bash
docker compose -f docker/docker-compose.yml pull
```
1. Run the following command to start the new Docker image:
```bash
docker compose -f docker/docker-compose.yml up -d
```
The container will automatically apply any required database schema migrations during startup.
### Home Server Systems (Community) ### Home Server Systems (Community)

49
docker/docker-compose.build.yml

@ -2,51 +2,22 @@ name: ghostfolio_build
services: services:
ghostfolio: ghostfolio:
build: ../ build: ../
container_name: ghostfolio-build image: ghostfolio/ghostfolio:local
init: true extends:
env_file: file: docker-compose.yml
- ../.env service: ghostfolio
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer
REDIS_HOST: redis
REDIS_PASSWORD: ${REDIS_PASSWORD}
ports:
- 3333:3333
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ['CMD-SHELL', 'curl -f http://localhost:3333/api/v1/health']
interval: 10s
timeout: 5s
retries: 5
postgres: postgres:
image: docker.io/library/postgres:15
container_name: gf-postgres-build container_name: gf-postgres-build
env_file: extends:
- ../.env file: docker-compose.yml
healthcheck: service: postgres
test: ['CMD-SHELL', 'pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}']
interval: 10s
timeout: 5s
retries: 5
volumes:
- postgres:/var/lib/postgresql/data
redis: redis:
image: docker.io/library/redis:alpine
container_name: gf-redis-build container_name: gf-redis-build
env_file: extends:
- ../.env file: docker-compose.yml
command: ['redis-server', '--requirepass', $REDIS_PASSWORD] service: redis
healthcheck:
test: ['CMD-SHELL', 'redis-cli --pass "$REDIS_PASSWORD" ping | grep PONG']
interval: 10s
timeout: 5s
retries: 5
volumes: volumes:
postgres: postgres:

17
docker/docker-compose.dev.yml

@ -1,23 +1,18 @@
name: ghostfolio_dev name: ghostfolio_dev
services: services:
postgres: postgres:
image: docker.io/library/postgres:15 extends:
file: docker-compose.yml
service: postgres
container_name: gf-postgres-dev container_name: gf-postgres-dev
restart: unless-stopped
env_file:
- ../.env
ports: ports:
- ${POSTGRES_PORT:-5432}:5432 - ${POSTGRES_PORT:-5432}:5432
volumes:
- postgres:/var/lib/postgresql/data
redis: redis:
image: docker.io/library/redis:alpine extends:
file: docker-compose.yml
service: redis
container_name: gf-redis-dev container_name: gf-redis-dev
restart: unless-stopped
env_file:
- ../.env
command: ['redis-server', '--requirepass', $REDIS_PASSWORD]
ports: ports:
- ${REDIS_PORT:-6379}:6379 - ${REDIS_PORT:-6379}:6379

20
docker/docker-compose.yml

@ -3,6 +3,7 @@ services:
ghostfolio: ghostfolio:
image: docker.io/ghostfolio/ghostfolio:latest image: docker.io/ghostfolio/ghostfolio:latest
container_name: ghostfolio container_name: ghostfolio
restart: unless-stopped
init: true init: true
cap_drop: cap_drop:
- ALL - ALL
@ -10,10 +11,6 @@ services:
- no-new-privileges:true - no-new-privileges:true
env_file: env_file:
- ../.env - ../.env
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer
REDIS_HOST: redis
REDIS_PASSWORD: ${REDIS_PASSWORD}
ports: ports:
- 3333:3333 - 3333:3333
depends_on: depends_on:
@ -28,8 +25,9 @@ services:
retries: 5 retries: 5
postgres: postgres:
image: docker.io/library/postgres:15 image: docker.io/library/postgres:15-alpine
container_name: gf-postgres container_name: gf-postgres
restart: unless-stopped
cap_drop: cap_drop:
- ALL - ALL
cap_add: cap_add:
@ -43,7 +41,8 @@ services:
env_file: env_file:
- ../.env - ../.env
healthcheck: healthcheck:
test: ['CMD-SHELL', 'pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}'] test:
['CMD-SHELL', 'pg_isready -d "$${POSTGRES_DB}" -U $${POSTGRES_USER}']
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5
@ -53,6 +52,7 @@ services:
redis: redis:
image: docker.io/library/redis:alpine image: docker.io/library/redis:alpine
container_name: gf-redis container_name: gf-redis
restart: unless-stopped
user: '999:1000' user: '999:1000'
cap_drop: cap_drop:
- ALL - ALL
@ -60,9 +60,13 @@ services:
- no-new-privileges:true - no-new-privileges:true
env_file: env_file:
- ../.env - ../.env
command: ['redis-server', '--requirepass', $REDIS_PASSWORD] command:
- /bin/sh
- -c
- redis-server --requirepass "$${REDIS_PASSWORD:?REDIS_PASSWORD variable is not set}"
healthcheck: healthcheck:
test: ['CMD-SHELL', 'redis-cli --pass "$REDIS_PASSWORD" ping | grep PONG'] test:
['CMD-SHELL', 'redis-cli --pass "$${REDIS_PASSWORD}" ping | grep PONG']
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5

Loading…
Cancel
Save