# ----------- Builder Stage ----------- FROM golang:1.24-alpine AS builder WORKDIR /app RUN apk update && apk add --no-cache build-base COPY go.mod go.sum ./ RUN go mod download COPY . . RUN go build -ldflags="-s -w" -o rentease main.go # Install air and templ for live reload and templating in dev RUN go install github.com/air-verse/air@latest \ && go install github.com/a-h/templ/cmd/templ@latest \ && rm -rf /go/pkg/mod /root/.cache/go-build # ----------- Dev Stage ----------- FROM golang:1.24-alpine AS dev WORKDIR /app # Install runtime dependencies RUN apk add --no-cache ca-certificates && apk add --no-cache golangci-lint # Copy only necessary files from builder COPY --from=builder /app/rentease ./rentease COPY --from=builder /app/assets ./assets COPY --from=builder /go/bin/air /go/bin/templ /go/bin/ COPY . . EXPOSE 8000 CMD ["air", "-c", ".air.toml"]