vetrag/Dockerfile

50 lines
1005 B
Docker

# ---- Builder Stage ----
FROM golang:1.25.1-bookworm AS builder
# Build Args
ARG BUILD_COMMAND="go build -o app ."
ARG BINARY_NAME="app"
ARG CGO_ENABLED="0"
# Env setup
ENV CGO_ENABLED=${CGO_ENABLED}
# Setup workdir
WORKDIR /build
# Copy go.mod and go.sum first to leverage caching
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build with Go build cache (requires BuildKit)
RUN ${BUILD_COMMAND}
# ---- Runner Stage ----
FROM debian:bookworm-slim AS runner
# Install minimal runtime dependencies (e.g. for TLS, CA certs)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Build Args
ARG BINARY_NAME="app"
# Setup workdir
WORKDIR /user
# Copy binary and config files
COPY --from=builder /build/${BINARY_NAME} ./app
COPY config.yaml .
COPY db.yaml .
COPY ui.html .
COPY ui_dbedit.html .
COPY ui_admin_chats.html .
EXPOSE 8080
# Run binary directly
ENTRYPOINT ["./app"]