-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.dlib-docker-go
58 lines (42 loc) · 1.81 KB
/
Dockerfile.dlib-docker-go
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
48
49
50
51
52
53
54
55
56
57
58
ARG BUILDER_IMAGE="ghcr.io/andriykalashnykov/dlib-docker:v19.24.4"
FROM ${BUILDER_IMAGE} AS builder
ARG GO_VER="1.23.2"
ARG DEBIAN_FRONTEND=noninteractive
#RUN DEBIAN_FRONTEND=${DEBIAN_FRONTEND} apt-get update && apt-get install -y --install-recommends libgfortran5 libquadmath0-amd64-cross libquadrule-dev
# 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/
# https://hub.docker.com/_/golang/
# Install Go
RUN curl -sLO https://go.dev/dl/go$GO_VER.linux-$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/').tar.gz \
&& tar -C /usr/local -xzf go$GO_VER.linux-$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/').tar.gz \
&& rm -rf go$GO_VER.linux-$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/').tar.gz
ENV PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/
RUN /usr/local/go/bin/go mod download
RUN <<EOT
if [ "${TARGETARCH}" = "amd64" ]; then
export CGO_LDFLAGS="-lcblas -llapack_atlas -lgfortran -lquadmath -lblas -latlas"
else
export CGO_LDFLAGS="-lcblas -llapack_atlas -lgfortran -lblas -latlas"
fi
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"]