-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
34 lines (24 loc) · 1.12 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM golang:1.23-bookworm as builder
WORKDIR /workspace
# install templ
RUN --mount=type=cache,target=$GOPATH/pkg/mod go install github.com/a-h/templ/cmd/templ@latest
# install task
RUN --mount=type=cache,target=$GOPATH/pkg/mod go install github.com/go-task/task/v3/cmd/task@latest
# install sqlboiler
RUN --mount=type=cache,target=$GOPATH/pkg/mod go install github.com/volatiletech/sqlboiler/v4@latest
RUN --mount=type=cache,target=$GOPATH/pkg/mod go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-sqlite3@latest
# cache deps
COPY go.mod go.sum ./
RUN --mount=type=cache,target=$GOPATH/pkg/mod go mod download
COPY . ./
# generate code
RUN --mount=type=cache,target=$GOPATH/pkg/mod go generate ./...
# build the final binary
RUN --mount=type=cache,target=$GOPATH/pkg/mod CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -trimpath -o app .
FROM debian:stable-slim
ENV TZ=Etc/UTC
ENV ZONEINFO=/zoneinfo.zip
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /workspace/app /usr/bin/app
ENTRYPOINT [ "app" ]