feat(docker): add migrate-config service for database migrations
Some checks failed
CI / build-and-test (push) Failing after -32m38s

* Include amcs-migrate-config binary in Docker image
* Document migration commands in README
This commit is contained in:
2026-04-21 21:18:34 +02:00
parent 14e218d784
commit 7f9c6f122e
4 changed files with 42 additions and 1 deletions

View File

@@ -29,7 +29,14 @@ RUN set -eu; \
-X git.warky.dev/wdevs/amcs/internal/buildinfo.TagName=${VERSION_TAG} \ -X git.warky.dev/wdevs/amcs/internal/buildinfo.TagName=${VERSION_TAG} \
-X git.warky.dev/wdevs/amcs/internal/buildinfo.Commit=${COMMIT_SHA} \ -X git.warky.dev/wdevs/amcs/internal/buildinfo.Commit=${COMMIT_SHA} \
-X git.warky.dev/wdevs/amcs/internal/buildinfo.BuildDate=${BUILD_DATE}" \ -X git.warky.dev/wdevs/amcs/internal/buildinfo.BuildDate=${BUILD_DATE}" \
-o /out/amcs-server ./cmd/amcs-server -o /out/amcs-server ./cmd/amcs-server; \
CGO_ENABLED=0 GOOS=linux go build -trimpath \
-ldflags="-s -w \
-X git.warky.dev/wdevs/amcs/internal/buildinfo.Version=${VERSION_TAG} \
-X git.warky.dev/wdevs/amcs/internal/buildinfo.TagName=${VERSION_TAG} \
-X git.warky.dev/wdevs/amcs/internal/buildinfo.Commit=${COMMIT_SHA} \
-X git.warky.dev/wdevs/amcs/internal/buildinfo.BuildDate=${BUILD_DATE}" \
-o /out/amcs-migrate-config ./cmd/amcs-migrate-config
FROM debian:bookworm-slim FROM debian:bookworm-slim
@@ -41,6 +48,7 @@ RUN apt-get update \
WORKDIR /app WORKDIR /app
COPY --from=builder /out/amcs-server /app/amcs-server COPY --from=builder /out/amcs-server /app/amcs-server
COPY --from=builder /out/amcs-migrate-config /app/amcs-migrate-config
COPY --chown=appuser:appuser configs /app/configs COPY --chown=appuser:appuser configs /app/configs
USER appuser USER appuser

View File

@@ -654,6 +654,22 @@ Notes:
- Database migrations `001` through `005` run automatically when the Postgres volume is created for the first time. - Database migrations `001` through `005` run automatically when the Postgres volume is created for the first time.
- `migrations/006_rls_and_grants.sql` is intentionally skipped during container bootstrap because it contains deployment-specific grants for a role named `amcs_user`. - `migrations/006_rls_and_grants.sql` is intentionally skipped during container bootstrap because it contains deployment-specific grants for a role named `amcs_user`.
### Run config migration with Compose
The container image now includes `/app/amcs-migrate-config`.
Dry-run (prints migrated YAML, does not write files):
```bash
docker compose --profile tools run --rm migrate-config --config /app/configs/dev.yaml --dry-run
```
Apply migration in-place (writes file + creates backup):
```bash
docker compose --profile tools run --rm migrate-config --config /app/configs/dev.yaml
```
## Ollama ## Ollama
Set your role targets to an Ollama provider to use a local or self-hosted Ollama server through its OpenAI-compatible API. Set your role targets to an Ollama provider to use a local or self-hosted Ollama server through its OpenAI-compatible API.

View File

@@ -78,3 +78,8 @@
- New: `internal/ai/runner_test.go` - New: `internal/ai/runner_test.go`
- New: `internal/config/migrate.go` - New: `internal/config/migrate.go`
- New: `internal/config/migrate_test.go` - New: `internal/config/migrate_test.go`
### 2026-04-21 21h - Docker Support for Config Migration CLI
- Added `amcs-migrate-config` binary to the Docker image build output.
- Added `migrate-config` service in `docker-compose.yml` under the `tools` profile.
- Documented compose-based migration commands (dry-run and in-place apply) in the README.

View File

@@ -36,6 +36,18 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
migrate-config:
build:
context: .
profiles: ["tools"]
restart: "no"
volumes:
- ./configs:/app/configs
environment:
AMCS_CONFIG: /app/configs/docker.yaml
entrypoint: ["/app/amcs-migrate-config"]
command: ["--config", "/app/configs/docker.yaml", "--dry-run"]
volumes: volumes:
postgres_data: postgres_data: