All checks were successful
continuous-integration/drone/push Build is passing
Replace hardcoded CMD arguments with ENV directives: - AETHERA_LISTEN=0.0.0.0 - AETHERA_PORT=8080 - AETHERA_DATA_DIR=/app/data This allows runtime configuration via docker run -e or compose files.
71 lines
1.5 KiB
Docker
71 lines
1.5 KiB
Docker
# Multi-stage build for Aethera
|
|
# Stage 1: Build frontend assets
|
|
FROM oven/bun:1 AS frontend-builder
|
|
|
|
WORKDIR /app/frontend
|
|
|
|
# Copy frontend package files
|
|
COPY frontend/package.json frontend/bun.lock ./
|
|
|
|
# Install dependencies
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# Copy frontend source code
|
|
COPY frontend/ ./
|
|
|
|
# Build frontend assets
|
|
RUN bun run build
|
|
|
|
# Stage 2: Build Go binary
|
|
FROM golang:1.25-alpine AS backend-builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git
|
|
|
|
# Copy go mod files
|
|
COPY backend/go.mod backend/go.sum ./
|
|
|
|
# Download Go dependencies
|
|
RUN go mod download
|
|
|
|
# Copy backend source code
|
|
COPY backend/ ./
|
|
|
|
# Copy frontend assets from previous stage
|
|
COPY --from=frontend-builder /app/frontend/public/dist ./public/dist
|
|
COPY --from=frontend-builder /app/frontend/public/index.html ./public/
|
|
COPY --from=frontend-builder /app/frontend/public/pages ./public/pages
|
|
|
|
# Build the Go binary
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o aethera ./cmd
|
|
|
|
# Stage 3: Create minimal runtime image
|
|
FROM alpine:3.21
|
|
|
|
# Install ca-certificates for HTTPS calls
|
|
RUN apk add --no-cache ca-certificates
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the binary from the builder stage
|
|
COPY --from=backend-builder /app/aethera .
|
|
|
|
# Copy static assets
|
|
COPY --from=backend-builder /app/public ./public
|
|
|
|
# Create data directory
|
|
RUN mkdir -p /app/data
|
|
|
|
# Expose the default port
|
|
EXPOSE 8080
|
|
|
|
# Set environment variable defaults
|
|
ENV AETHERA_LISTEN=0.0.0.0
|
|
ENV AETHERA_PORT=8080
|
|
ENV AETHERA_DATA_DIR=/app/data
|
|
|
|
# Set the entrypoint
|
|
ENTRYPOINT ["./aethera"]
|