refactor: réorganiser Dockerfiles et scripts par module
Réorganise la structure Docker pour plus de cohérence dans le monorepo. Chaque module (backend, docs) a maintenant ses propres Dockerfiles et scripts. Changements: - backend/docker/ : Dockerfile (prod) + dev.Dockerfile (hot reload) + init script - docs/docker/ : mkdocs.Dockerfile + pdf.Dockerfile - docs/scripts/ : generate-bdd-docs.py + generate-pdf-docs.py - Déplace docker-compose.yml dans backend/ - Supprime scripts obsolètes (fix-markdown-*.sh, remove-broken-links.sh) - Déplace .dockerignore à la racine - Met à jour Makefile avec nouveaux chemins Organisation finale: - backend/ : tout ce qui concerne l'API backend - docs/ : tout ce qui concerne la documentation - scripts/ : uniquement setup.sh (scripts généraux du projet)
This commit is contained in:
33
backend/docker/Dockerfile
Normal file
33
backend/docker/Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
# Builder stage
|
||||
FROM golang:1.23-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache git ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-w -s" -o /bin/api ./cmd/api
|
||||
|
||||
# Final stage
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk --no-cache add ca-certificates ffmpeg
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
# Copy binary from builder
|
||||
COPY --from=builder /bin/api .
|
||||
|
||||
# Copy config files
|
||||
COPY config/ ./config/
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./api"]
|
||||
25
backend/docker/dev.Dockerfile
Normal file
25
backend/docker/dev.Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
FROM golang:1.23-alpine
|
||||
|
||||
RUN apk add --no-cache git ca-certificates make
|
||||
|
||||
# Install Air for hot reload
|
||||
RUN go install github.com/cosmtrek/air@latest
|
||||
|
||||
# Install sqlc
|
||||
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
||||
|
||||
# Install migrate
|
||||
RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["air", "-c", ".air.toml"]
|
||||
23
backend/docker/init-multiple-databases.sh
Executable file
23
backend/docker/init-multiple-databases.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# Script to create multiple databases in PostgreSQL container
|
||||
# Used by docker-compose to create both roadwave_dev and zitadel databases
|
||||
|
||||
function create_database() {
|
||||
local database=$1
|
||||
echo "Creating database '$database'"
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
|
||||
CREATE DATABASE $database;
|
||||
GRANT ALL PRIVILEGES ON DATABASE $database TO $POSTGRES_USER;
|
||||
EOSQL
|
||||
}
|
||||
|
||||
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
|
||||
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES"
|
||||
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do
|
||||
create_database $db
|
||||
done
|
||||
echo "Multiple databases created"
|
||||
fi
|
||||
Reference in New Issue
Block a user