From 0227c8305727a82e9d4f20c7e2245e8daf4f0cc5 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Sun, 11 May 2025 01:11:05 +0200 Subject: [PATCH] feat(docker): add multi-stage build for Deno application - Introduces a multi-stage Dockerfile to build and run a Deno app - Uses a builder stage to compile the app into a self-contained binary - Adds minimal runtime stage with environment variable configuration - Improves container efficiency and reduces runtime dependencies --- Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6ff0028 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +# -------- Stage 1: Build the Deno application -------- +FROM denoland/deno:latest AS builder + +# Set the working directory inside the builder container +WORKDIR /app + +# Copy the application source code and configuration files +COPY src/ ./src/ +COPY deno.jsonc ./deno.jsonc +COPY import_map.json ./import_map.json + +# Compile the application to a self-contained native binary +# Permissions and flags should be specified during compile time +RUN deno task compile + +# -------- Stage 2: Minimal runtime environment -------- +FROM denoland/deno:alpine + +# Optional: Install curl for container-level health checks (not needed for production-only binaries) +RUN apk add --no-cache curl + +# Copy only the compiled application binary from the builder stage +COPY --from=builder /app/app /app/app + +# Set the working directory for the runtime container +WORKDIR /app + +# Define expected environment variables (can be overridden at runtime) +ENV PROXY_HOST=0.0.0.0 +ENV PROXY_PORT=8011 +ENV LT_SERVER_HOST=localhost +ENV LT_SERVER_PORT=8010 +ENV API_KEYS=demo-key + +# Define the default command to run the application binary +CMD ["/app/app"]