-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (22 loc) · 783 Bytes
/
Dockerfile
File metadata and controls
34 lines (22 loc) · 783 Bytes
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
# syntax=docker/dockerfile:1
FROM golang:1.22-alpine AS BUILD
ENV CGO_ENABLED 0
ENV GOPATH /go
ENV GOCACHE /go-build
RUN apk add build-base alpine-sdk
WORKDIR /app
# RUN apk update && apk add --no-cache musl-dev gcc build-base
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod/cache \
go mod download && go mod verify
# copy the rest of the files
COPY . .
# build the binary
RUN --mount=type=cache,target=/go/pkg/mod/cache \
--mount=type=cache,target=/go-build \
go build -a -installsuffix cgo -v -o /app/bot cmd/bot/entry.go
FROM alpine as deployment
WORKDIR /app
COPY --from=BUILD /app/bot /app/bot
ENTRYPOINT ["/app/bot"]