27 lines
458 B
Docker
27 lines
458 B
Docker
# Stage 1: Builder
|
|
FROM golang:1.22.5-alpine AS builder
|
|
RUN apk add --no-cache gcc g++
|
|
|
|
WORKDIR /app
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
|
RUN go install github.com/a-h/templ/cmd/templ@latest
|
|
RUN templ generate
|
|
|
|
COPY . .
|
|
|
|
RUN go build -o todos-app
|
|
|
|
# Stage 2: Final Image
|
|
FROM alpine:3.19
|
|
|
|
RUN apk add --no-cache bash
|
|
WORKDIR /app
|
|
VOLUME /app/data
|
|
|
|
COPY --from=builder /app/todos-app .
|
|
COPY --from=builder /app/static /app/static
|
|
|
|
CMD ["./todos-app"]
|