feat(docker): add multi-stage build for Deno application
Some checks failed
Build and upload Docker nightly image / build-and-push (push) Failing after 14s
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / changelog-only (push) Has been skipped
Auto Changelog & Release / release (push) Successful in 2m5s
Some checks failed
Build and upload Docker nightly image / build-and-push (push) Failing after 14s
Auto Changelog & Release / detect-version-change (push) Successful in 5s
Auto Changelog & Release / changelog-only (push) Has been skipped
Auto Changelog & Release / release (push) Successful in 2m5s
- 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
This commit is contained in:
36
Dockerfile
Normal file
36
Dockerfile
Normal file
@@ -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"]
|
Reference in New Issue
Block a user