ddns/Dockerfile
2025-05-03 18:24:28 -03:00

27 lines
703 B
Docker

############################
# STEP 1: Build executable
############################
FROM golang:1.24.1-alpine AS builder
RUN apk add --no-cache git build-base sqlite-dev
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go install github.com/a-h/templ/cmd/templ@latest
RUN templ generate
RUN CGO_ENABLED=1 go build -o ddns-manager .
############################
# STEP 2: Build final image
############################
FROM alpine:latest
RUN apk add --no-cache sqlite-libs ca-certificates tzdata
WORKDIR /app
COPY --from=builder /app/ddns-manager /app/
COPY --from=builder /app/assets /app/assets
VOLUME /data
EXPOSE 3000
ENV DB_PATH=/data/ddns.db
ENTRYPOINT ["/app/ddns-manager"]