-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.go-face
47 lines (35 loc) · 1.17 KB
/
Dockerfile.go-face
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
35
36
37
38
39
40
41
42
43
44
45
46
47
ARG BUILDER_IMAGE="ghcr.io/andriykalashnykov/go-face:v0.0.1"
FROM ${BUILDER_IMAGE} AS builder
# Set the working directory
WORKDIR /app
# Copy go modules files
COPY ./go.mod .
COPY ./go.sum .
# Copy the source code
COPY ./cmd/ cmd/
COPY ./internal/ internal/
# Copy the recources
COPY ./fonts/ fonts/
COPY ./images/ images/
COPY ./models/ models/
COPY ./persons/ persons/
ENV PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/
RUN <<EOT
if [ "${TARGETARCH}" = "amd64" ]; then
apt install -y libquadmath0;
export CGO_LDFLAGS="-lcblas -llapack_atlas -lgfortran -lquadmath -lblas -latlas"
else
export CGO_LDFLAGS="-lcblas -llapack_atlas -lgfortran -lblas -latlas"
fi
/usr/local/go/bin/go mod download
CGO_ENABLED=1 /usr/local/go/bin/go build -trimpath -ldflags "-s -w -extldflags -static" -tags "static netgo cgo static_build" -o cmd/main cmd/main.go
EOT
FROM alpine:3.20.3 AS runtime
WORKDIR /app
COPY --from=builder /app/cmd/main .
COPY --from=builder /app/fonts fonts/
COPY --from=builder /app/images/ images/
COPY --from=builder /app/models/ models/
COPY --from=builder /app/persons/ persons/
# Keep the container running
CMD ["tail", "-f", "/dev/null"]