Dockerfile (view raw)
1# syntax=docker/dockerfile:1
2
3FROM golang:1.23-alpine AS builder
4
5
6WORKDIR /build
7
8# Download Git submodules
9# COPY .git ./.git
10# RUN git -c submodule.ui.update=none submodule update --init --recursive
11
12# Download Go modules
13COPY go.mod go.sum ./
14RUN go mod download
15RUN go mod verify
16
17# Transfer source code
18COPY .git/refs/heads/main ./commitID
19COPY *.go ./
20COPY src ./src
21
22# Build
23RUN commit_hash=$(cat commitID | cut -c1-7) && \
24 CGO_ENABLED=0 go build -ldflags "-X github.com/BiRabittoh/disgord/src/globals.CommitID=$commit_hash" -trimpath -o /dist/app
25
26
27# Test
28FROM builder AS run-test-stage
29# COPY i18n ./i18n
30RUN go test -v ./...
31
32FROM alpine AS build-release-stage
33
34RUN apk add --no-cache ffmpeg
35
36WORKDIR /app
37
38COPY --from=builder /dist .
39ENTRYPOINT ["./app"]