docs: add section on dev services

This commit is contained in:
2025-07-11 10:26:51 +02:00
parent 21abbe97ed
commit 6313bc5ec7

View File

@@ -116,21 +116,23 @@ docker compose exec step step ca provisioner update acme \
--x509-default-dur=2160h
```
### Use the preconfigured services
### Create a shell script to start/stop general services
If you use the preconfigured services, you can add the following snippet to you `.bashrc`/`.zshrc` to easily start, stop, and manage the services.
I often use `dbgate` to interact with databases. For services like that i setup a `services/compose.yml` inside this directory where I define each service i use with a custom profile so that i can start and stop them individually.
If you use the preconfigured services, you can add the following snippet to you `.bashrc`/`.zshrc` to easily start, stop, and manage the services. Make sure to update the `PROJECT_DIR` variable to point to the correct directory.
```shell
dev () {
PROJECT_DIR="$HOME/Projects/dev/services"
case "$1" in
(start) shift
docker compose -f "$PROJECT_DIR/docker-compose.yml" --profile "$@" up -d ;;
docker compose -f "$PROJECT_DIR/compose.yml" --profile "$@" up -d ;;
(restart) shift
docker compose -f "$PROJECT_DIR/docker-compose.yml" --profile "$@" restart ;;
docker compose -f "$PROJECT_DIR/compose.yml" --profile "$@" restart ;;
(stop) shift
docker compose -f "$PROJECT_DIR/docker-compose.yml" --profile "$@" down --remove-orphans ;;
docker compose -f "$PROJECT_DIR/compose.yml" --profile "$@" down --remove-orphans ;;
(logs) shift
docker compose -f "$PROJECT_DIR/docker-compose.yml" --profile "$@" logs -f ;;
docker compose -f "$PROJECT_DIR/compose.yml" --profile "$@" logs -f ;;
(*) echo "Usage: dev {start|restart|stop|logs} [services...]" ;;
esac
}