echo-todos/Dockerfile

28 lines
458 B
Docker
Raw Normal View History

2024-08-19 12:56:20 +00:00
# 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"]