Files
ackify-ce/Dockerfile
Benjamin 24e2de2922 refactor(arch): enforce strict layered architecture with private interfaces
Apply Clean Architecture principles throughout the codebase to eliminate tight coupling between layers. Handlers now depend exclusively on services through private interfaces, never directly on repositories.
Introduce a ServerBuilder pattern with pluggable capability providers.

refactor(auth): introduce injectable AuthorizerService

Replace hardcoded AdminEmails and OnlyAdminCanCreate config fields
with an injectable AuthorizerService. This improves testability and
follows the dependency injection pattern used elsewhere in the codebase.

- Create AuthorizerService in application/services/
- Define minimal Authorizer interfaces in consuming packages
- Update middleware, handlers, and router to use injected authorizer
- Update all affected tests with mock implementations

refactor(build): move go.mod to backend directory
Move Go module files from project root to backend/ directory while keeping the module name as github.com/btouchard/ackify-ce.
This improves project structure by keeping Go-specific files within the Go codebase directory.

# Conflicts:
#	backend/internal/application/services/checksum_service_test.go
#	backend/internal/application/services/document_service.go
#	backend/internal/application/services/document_service_duplicate_test.go
#	backend/internal/application/services/document_service_test.go
#	backend/internal/presentation/api/documents/handler.go
#	backend/internal/presentation/api/documents/handler_test.go
#	backend/internal/presentation/api/router.go
#	backend/pkg/web/server.go
2025-12-08 16:07:03 +01:00

85 lines
2.8 KiB
Docker

# syntax=docker/dockerfile:1.7
# Build the SPA with the build platform to avoid slow QEMU emulation on arm64
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS spa-builder
WORKDIR /app/webapp
COPY webapp/package*.json ./
# Speed up and stabilize npm installs in CI
# - no-audit/no-fund: skip network calls
# - no-progress: cleaner logs
# - cache mount: reuse npm cache between builds
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit --no-fund --no-progress
COPY webapp/ ./
# Enable code instrumentation for E2E coverage if requested
ARG CYPRESS_COVERAGE=false
ENV CYPRESS_COVERAGE=$CYPRESS_COVERAGE
RUN npm run build
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache ca-certificates git curl && rm -rf /var/cache/apk/*
RUN adduser -D -g '' ackuser
WORKDIR /app/backend
COPY backend/go.mod backend/go.sum ./
ENV GOTOOLCHAIN=auto
# Cache Go modules and build cache between builds
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download && go mod verify
COPY backend/ ./
RUN mkdir -p cmd/community/web/dist
COPY --from=spa-builder /app/webapp/dist ./cmd/community/web/dist
# Cross-compile per target platform
ARG TARGETOS
ARG TARGETARCH
ARG VERSION="dev"
ARG COMMIT="unknown"
ARG BUILD_DATE="unknown"
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
-a -installsuffix cgo \
-ldflags="-w -s -X main.Version=${VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${BUILD_DATE}" \
-o /app/ackify ./cmd/community
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
-a -installsuffix cgo \
-ldflags="-w -s" \
-o /app/migrate ./cmd/migrate
FROM gcr.io/distroless/static-debian12:nonroot
ARG VERSION="dev"
LABEL maintainer="Benjamin TOUCHARD"
LABEL version="${VERSION}"
LABEL description="Ackify - Document signature validation platform"
LABEL org.opencontainers.image.source="https://github.com/btouchard/ackify-ce"
LABEL org.opencontainers.image.description="Professional solution for validating and tracking document reading"
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
WORKDIR /app
COPY --from=builder /app/ackify /app/ackify
COPY --from=builder /app/migrate /app/migrate
COPY --from=builder /app/backend/migrations /app/migrations
COPY --from=builder /app/backend/locales /app/locales
COPY --from=builder /app/backend/templates /app/templates
COPY --from=builder /app/backend/openapi.yaml /app/openapi.yaml
ENV ACKIFY_TEMPLATES_DIR=/app/templates
ENV ACKIFY_LOCALES_DIR=/app/locales
EXPOSE 8080
ENTRYPOINT ["/app/ackify"]