Skip to content

Commit be456a6

Browse files
Add Docker workflows, compose prod & ignores
Add GitHub Actions to build/push multi-arch Docker images (gateway + web) and a CI job to validate docker-compose files. Include a new docker.yml workflow for Buildx/QEMU, a compose-validate job in ci.yml, and a production docker-compose.prod.yml for running GHCR images. Add top-level and web/.dockerignore files and exclude web/ from gofmt checks. Update README with Docker-first quick start instructions and make a trivial import reorder in cmd/gateway/main.go.
1 parent 2d0a2b6 commit be456a6

7 files changed

Lines changed: 281 additions & 3 deletions

File tree

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Git
2+
.git/
3+
.github/
4+
5+
# Dev artifacts
6+
.local/
7+
coverage.out
8+
*.coverprofile
9+
10+
# Docs / scripts (not needed in the image)
11+
docs/
12+
scripts/
13+
14+
# Frontend source (built separately in web/Dockerfile)
15+
web/
16+
17+
# Editor
18+
.vscode/
19+
.idea/

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Verify formatting (gofmt)
2929
shell: bash
3030
run: |
31-
files=$(find . -name '*.go' -not -path './.local/*')
31+
files=$(find . -name '*.go' -not -path './.local/*' -not -path './web/*')
3232
out=$(gofmt -l $files)
3333
if [ -n "$out" ]; then
3434
echo "The following files are not gofmt-formatted:"
@@ -53,3 +53,16 @@ jobs:
5353
fail_ci_if_error: false
5454
env:
5555
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
56+
57+
compose-validate:
58+
name: Validate Docker Compose files
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Validate docker-compose.yml (dev)
65+
run: docker compose -f docker-compose.yml config --quiet
66+
67+
- name: Validate docker-compose.prod.yml (prod)
68+
run: docker compose -f docker-compose.prod.yml config --quiet

.github/workflows/docker.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Builds and pushes multi-arch Docker images to GitHub Container Registry.
2+
#
3+
# Triggers:
4+
# - Push of a version tag (v*) → builds & pushes :vX.Y.Z + :latest
5+
# - Pull request to main → build-only (no push), validates Dockerfiles
6+
#
7+
# Images produced:
8+
# ghcr.io/<owner>/verifhir-gateway:vX.Y.Z (gateway Go binary)
9+
# ghcr.io/<owner>/verifhir-gateway:latest
10+
# ghcr.io/<owner>/verifhir-web:vX.Y.Z (React UI via nginx)
11+
# ghcr.io/<owner>/verifhir-web:latest
12+
#
13+
# Architectures: linux/amd64, linux/arm64
14+
15+
name: Docker
16+
17+
on:
18+
push:
19+
tags:
20+
- "v*"
21+
pull_request:
22+
branches:
23+
- main
24+
25+
env:
26+
REGISTRY: ghcr.io
27+
GATEWAY_IMAGE: ghcr.io/${{ github.repository_owner }}/verifhir-gateway
28+
WEB_IMAGE: ghcr.io/${{ github.repository_owner }}/verifhir-web
29+
30+
jobs:
31+
build-gateway:
32+
name: Gateway image
33+
runs-on: ubuntu-latest
34+
permissions:
35+
contents: read
36+
packages: write
37+
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Set up QEMU (for ARM64 emulation)
43+
uses: docker/setup-qemu-action@v3
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
48+
- name: Log in to GHCR
49+
if: github.event_name != 'pull_request'
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Docker metadata (tags & labels)
57+
id: meta
58+
uses: docker/metadata-action@v5
59+
with:
60+
images: ${{ env.GATEWAY_IMAGE }}
61+
tags: |
62+
type=semver,pattern={{version}}
63+
type=semver,pattern={{major}}.{{minor}}
64+
type=raw,value=latest,enable={{is_default_branch}}
65+
66+
- name: Build and push gateway
67+
uses: docker/build-push-action@v6
68+
with:
69+
context: .
70+
file: Dockerfile
71+
platforms: linux/amd64,linux/arm64
72+
push: ${{ github.event_name != 'pull_request' }}
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
78+
build-web:
79+
name: Web image
80+
runs-on: ubuntu-latest
81+
permissions:
82+
contents: read
83+
packages: write
84+
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v4
88+
89+
- name: Set up QEMU
90+
uses: docker/setup-qemu-action@v3
91+
92+
- name: Set up Docker Buildx
93+
uses: docker/setup-buildx-action@v3
94+
95+
- name: Log in to GHCR
96+
if: github.event_name != 'pull_request'
97+
uses: docker/login-action@v3
98+
with:
99+
registry: ${{ env.REGISTRY }}
100+
username: ${{ github.actor }}
101+
password: ${{ secrets.GITHUB_TOKEN }}
102+
103+
- name: Docker metadata
104+
id: meta
105+
uses: docker/metadata-action@v5
106+
with:
107+
images: ${{ env.WEB_IMAGE }}
108+
tags: |
109+
type=semver,pattern={{version}}
110+
type=semver,pattern={{major}}.{{minor}}
111+
type=raw,value=latest,enable={{is_default_branch}}
112+
113+
- name: Build and push web
114+
uses: docker/build-push-action@v6
115+
with:
116+
context: ./web
117+
file: ./web/Dockerfile
118+
platforms: linux/amd64,linux/arm64
119+
push: ${{ github.event_name != 'pull_request' }}
120+
tags: ${{ steps.meta.outputs.tags }}
121+
labels: ${{ steps.meta.outputs.labels }}
122+
cache-from: type=gha
123+
cache-to: type=gha,mode=max

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,74 @@ This repository contains an initial skeleton with a working bootstrap pipeline:
3131

3232
## Quick Start
3333

34-
### Prerequisites
34+
### Opção 1 — Docker (recomendado, sem precisar do código fonte)
35+
36+
**Pré-requisitos:** Docker Desktop ou Docker Engine com Compose v2.
37+
38+
```bash
39+
# 1. Baixar o compose de produção
40+
curl -O https://raw.githubusercontent.com/vagnercazarotto/verifhir-gateway/main/docker-compose.prod.yml
41+
42+
# 2. Subir (as imagens são puxadas automaticamente do GHCR)
43+
docker compose -f docker-compose.prod.yml up -d
44+
```
45+
46+
Abrir no browser: **http://localhost:3000**
47+
48+
| Porta | Serviço |
49+
|---|---|
50+
| 3000 | Web UI (React) |
51+
| 8080 | REST API |
52+
| 2575 | MLLP listener |
53+
54+
**Atualizar para a versão mais recente:**
55+
56+
```bash
57+
docker compose -f docker-compose.prod.yml pull
58+
docker compose -f docker-compose.prod.yml up -d
59+
```
60+
61+
**Fixar versão específica** (recomendado em produção) — editar o arquivo e substituir `latest` por ex. `v0.2.0`:
62+
63+
```yaml
64+
image: ghcr.io/vagnercazarotto/verifhir-gateway:v0.2.0
65+
image: ghcr.io/vagnercazarotto/verifhir-web:v0.2.0
66+
```
67+
68+
**Parar e remover:**
69+
70+
```bash
71+
docker compose -f docker-compose.prod.yml down
72+
```
73+
74+
---
75+
76+
### Opção 2 — Desenvolvimento local (com código fonte)
77+
78+
**Pré-requisitos:** Go 1.25+, Node 22+, Docker Desktop.
79+
80+
```bash
81+
git clone https://github.com/vagnercazarotto/verifhir-gateway.git
82+
cd verifhir-gateway
83+
84+
# Subir tudo com build local
85+
docker compose up --build -d
86+
```
87+
88+
Ou rodar cada serviço separadamente:
89+
90+
```bash
91+
# Terminal 1 — Gateway Go
92+
mkdir -p .local
93+
go run ./cmd/gateway
94+
95+
# Terminal 2 — Web UI (dev server com hot-reload)
96+
cd web && npm install && npm run dev
97+
```
98+
99+
Web UI disponível em **http://localhost:5173** (proxy automático para a API em :8080).
100+
101+
### Prerequisites (legacy scripts)
35102

36103
- Go 1.22+
37104

cmd/gateway/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"syscall"
1111
"time"
1212

13-
"github.com/vagnercazarotto/verifhir-gateway/internal/audit"
1413
"github.com/vagnercazarotto/verifhir-gateway/internal/api/rest"
14+
"github.com/vagnercazarotto/verifhir-gateway/internal/audit"
1515
"github.com/vagnercazarotto/verifhir-gateway/internal/channel"
1616
"github.com/vagnercazarotto/verifhir-gateway/internal/config"
1717
"github.com/vagnercazarotto/verifhir-gateway/internal/ingest/mllp"

docker-compose.prod.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# VeriFHIR Gateway — Production deployment
2+
#
3+
# Usage:
4+
# curl -O https://raw.githubusercontent.com/vagnercazarotto/verifhir-gateway/main/docker-compose.prod.yml
5+
# docker compose -f docker-compose.prod.yml up -d
6+
#
7+
# Images are pulled from GitHub Container Registry (no build required).
8+
# Pin a specific version by replacing "latest" with e.g. "v0.2.0".
9+
10+
services:
11+
gateway:
12+
image: ghcr.io/vagnercazarotto/verifhir-gateway:latest
13+
pull_policy: always
14+
ports:
15+
- "8080:8080" # REST API
16+
- "2575:2575" # MLLP
17+
environment:
18+
- GATEWAY_HTTP_PORT=8080
19+
- GATEWAY_MLLP_ADDR=0.0.0.0:2575
20+
- GATEWAY_DB_PATH=.local/verifhir.db
21+
# To use PostgreSQL instead of SQLite, uncomment and set DATABASE_URL:
22+
# - DATABASE_URL=postgres://user:pass@db:5432/verifhir?sslmode=disable
23+
volumes:
24+
- gateway-data:/app/.local
25+
restart: unless-stopped
26+
healthcheck:
27+
test: ["CMD", "wget", "-qO-", "http://localhost:8080/healthz"]
28+
interval: 15s
29+
timeout: 5s
30+
retries: 3
31+
32+
web:
33+
image: ghcr.io/vagnercazarotto/verifhir-web:latest
34+
pull_policy: always
35+
ports:
36+
- "3000:80"
37+
depends_on:
38+
gateway:
39+
condition: service_healthy
40+
restart: unless-stopped
41+
42+
volumes:
43+
gateway-data:

web/.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Git
2+
.git/
3+
.github/
4+
5+
# Go source (already built before this runs)
6+
../../cmd/
7+
../../internal/
8+
../../go.mod
9+
../../go.sum
10+
11+
# Dev artifacts
12+
node_modules/
13+
dist/

0 commit comments

Comments
 (0)