Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

feat: optimiser les Dockerfiles avec entrypoint séparé et suppression de migrate CLI

Samuel BAGATTIN85311289b8e2
diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile
index a451d008..84d7ed4f 100644
--- a/docker/backend/Dockerfile
+++ b/docker/backend/Dockerfile
@@ -15,42 +15,18 @@ COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o backend_app .
-# Production stage
-FROM alpine:latest
-
-# Install required packages
-RUN apk --no-cache add ca-certificates tzdata mysql-client netcat-openbsd wget
-
-# Install migrate tool for database migrations - detect architecture
-RUN ARCH=$(uname -m) && \
- case $ARCH in \
- x86_64) MIGRATE_ARCH="amd64" ;; \
- aarch64) MIGRATE_ARCH="arm64" ;; \
- *) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
- esac && \
- wget -O- https://github.com/golang-migrate/migrate/releases/latest/download/migrate.linux-${MIGRATE_ARCH}.tar.gz | tar xvz && \
- mv migrate /usr/local/bin/migrate
-
-# Create app user
-RUN addgroup -g 1001 -S appgroup && \
- adduser -S appuser -G appgroup -u 1001
+# Production stage - distroless
+FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /app
# Copy built application
-COPY --from=builder --chown=appuser:appgroup /app/backend_app ./
-COPY --chown=appuser:appgroup config.toml ./
-COPY --chown=appuser:appgroup migrations ./migrations/
-
-# Switch to app user
-USER appuser
+COPY --from=builder --chown=nonroot:nonroot /app/backend_app ./
+COPY --chown=nonroot:nonroot config.toml ./
+COPY --chown=nonroot:nonroot migrations ./migrations/
# Expose port
EXPOSE 8201
-# Health check
-HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
- CMD nc -z localhost 8201 || exit 1
-
# Default command
-CMD ["./backend_app"]
\ No newline at end of file
+ENTRYPOINT ["./backend_app"]
\ No newline at end of file
diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile
index 39181891..32f5f8ba 100644
--- a/docker/frontend/Dockerfile
+++ b/docker/frontend/Dockerfile
@@ -20,17 +20,8 @@ RUN bun install
# Copy source code
COPY . .
-# Create entrypoint script that builds with current environment variables
-COPY <<EOF /app/entrypoint.sh
-#!/bin/bash
-echo "Building application with current environment variables..."
-echo "API: \$VITE_BASE_API"
-echo "CDN: \$VITE_BASE_CDN"
-echo "URL: \$NUXT_PUBLIC_BASE_URL"
-bun run build
-echo "Starting Nitro server..."
-exec bun .output/server/index.mjs
-EOF
+# Copy entrypoint script
+COPY ../docker/frontend/entrypoint.sh /app/entrypoint.sh
# Make script executable and change ownership to app user
RUN chmod +x /app/entrypoint.sh && \
diff --git a/docker/frontend/entrypoint.sh b/docker/frontend/entrypoint.sh
new file mode 100644
index 00000000..842ed8f0
--- /dev/null
+++ b/docker/frontend/entrypoint.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+echo "Building application with current environment variables..."
+echo "API: $VITE_BASE_API"
+echo "CDN: $VITE_BASE_CDN"
+echo "URL: $NUXT_PUBLIC_BASE_URL"
+bun run build
+echo "Starting Nitro server..."
+exec bun .output/server/index.mjs
\ No newline at end of file