cross compile files for extract embeddings exec
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
ARG BUILDPLATFORM=linux/amd64
|
||||
FROM --platform=$BUILDPLATFORM golang:1.26-bookworm AS builder
|
||||
|
||||
# Install dlib deps
|
||||
RUN dpkg --add-architecture arm64 && \
|
||||
apt-get update && apt-get install -y \
|
||||
g++-aarch64-linux-gnu \
|
||||
libdlib-dev:arm64 \
|
||||
libjpeg-dev:arm64 \
|
||||
libblas-dev:arm64 \
|
||||
libopenblas-dev:arm64 \
|
||||
libatlas-base-dev:arm64 \
|
||||
liblapack-dev:arm64 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Compiler wrapper for arm64
|
||||
RUN printf '#!/bin/bash\nexec aarch64-linux-gnu-gcc "${@//-march=native/-march=armv8-a}"\n' \
|
||||
> /usr/local/bin/arm64-gcc && \
|
||||
printf '#!/bin/bash\nexec aarch64-linux-gnu-g++ "${@//-march=native/-march=armv8-a}"\n' \
|
||||
> /usr/local/bin/arm64-g++ && \
|
||||
chmod +x /usr/local/bin/arm64-gcc /usr/local/bin/arm64-g++
|
||||
|
||||
# Compiler variables for cross-compile to arm64
|
||||
ENV CGO_ENABLED=1 \
|
||||
GOOS=linux \
|
||||
GOARCH=arm64 \
|
||||
CC=/usr/local/bin/arm64-gcc \
|
||||
CXX=/usr/local/bin/arm64-g++ \
|
||||
PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Pre-compile all CGO deps into cache
|
||||
RUN go build -v ./... 2>/dev/null || \
|
||||
go list -m all && \
|
||||
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 \
|
||||
go build -gcflags="-trimpath" -v \
|
||||
$(go list -f '{{if .CgoFiles}}{{.ImportPath}}{{end}}' ./...) 2>/dev/null; exit 0
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg \
|
||||
go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
# Build - reuse CGO cache
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg \
|
||||
go build -o extractEmbeddings
|
||||
|
||||
FROM scratch AS export
|
||||
COPY --from=builder /app/extractEmbeddings /extractEmbeddings
|
||||
@@ -0,0 +1,10 @@
|
||||
all:
|
||||
docker buildx build --platform linux/amd64 --cache-from type=local,src=./.docker-cache --cache-to type=local,dest=./.docker-cache --target export --output type=local,dest=./output .
|
||||
|
||||
models:
|
||||
wget https://github.com/Kagami/go-face-testdata/raw/master/models/shape_predictor_5_face_landmarks.dat
|
||||
wget https://github.com/Kagami/go-face-testdata/raw/master/models/dlib_face_recognition_resnet_model_v1.dat
|
||||
wget https://github.com/Kagami/go-face-testdata/raw/master/models/mmod_human_face_detector.dat
|
||||
|
||||
clean:
|
||||
rm -r output/
|
||||
@@ -0,0 +1,8 @@
|
||||
module OfficeSense/extractEmbeddings
|
||||
|
||||
go 1.26.3
|
||||
|
||||
require (
|
||||
github.com/Kagami/go-face v0.0.0-20210630145111-0c14797b4d0e
|
||||
golang.org/x/image v0.41.0
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
github.com/Kagami/go-face v0.0.0-20210630145111-0c14797b4d0e h1:lqIUFzxaqyYqUn4MhzAvSAh4wIte/iLNcIEWxpT/qbc=
|
||||
github.com/Kagami/go-face v0.0.0-20210630145111-0c14797b4d0e/go.mod h1:9wdDJkRgo3SGTcFwbQ7elVIQhIr2bbBjecuY7VoqmPU=
|
||||
golang.org/x/image v0.41.0 h1:8wS72eGJMJaBxK6okTzd4WaXumUlTVlb753MlsSvTCo=
|
||||
golang.org/x/image v0.41.0/go.mod h1:uIc348UZMSvS5Z65CVZ7iDPaNobNFEPeJ4kbqTOszmA=
|
||||
Reference in New Issue
Block a user