Comments (6)
Should be possible in case of dlib, not sure about mkl. Might try with e.g. openblas instead.
from go-face.
Closing because it's out of scope of go-face.
Should be possible with something like CGO_LDFLAGS="-static"
but don't have time to test this, because you also need static (.a
) version of all libraries that dlib depends on.
from go-face.
@frpunzalan I managed to build go-face application statically in docker.
Its based on Ubuntu 19.04 base image.
Dockerfile.ubuntu19.04
FROM ubuntu:19.04 as base
RUn apt-get update
RUN apt-get update && apt-get install pkg-config libdlib-dev libopenblas-dev libgfortran-8-dev libjpeg-turbo8-dev -y
ADD dlib-1.pc /usr/local/lib/pkgconfig/
RUN pkg-config --cflags -- dlib-1
dlib-1.pc
libdir=/usr/lib/x86_64-linux-gnu
includedir=/usr/include
Name: dlib
Description: Numerical and networking C++ library
Version: 19.10.0
Libs: -L${libdir} -ldlib -lblas -llapack -lgfortran -lquadmath
Cflags: -I${includedir}
Requires:
These two files give you basic environment with dev dependencies ready for static build. I named this image dlibubuntu
Next goes golang 1.13.8 base image with go-face library built in the $GOPATH
Because go-face installation takes much time I decided to make it as separate docker image.
FROM dlibubuntu as builder
RUN apt-get install wget git gcc -y
RUN wget https://dl.google.com/go/go1.13.8.linux-amd64.tar.gz
RUN tar -xf go1.13.8.linux-amd64.tar.gz
RUN mv go /usr/local
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
RUN mkdir $GOPATH
RUN go get -v github.com/Kagami/go-face
Last one. Your golang application which is using go-face. Basically app the same as example one. I provide here only its Dockerfile.
FROM goface:latest as builder
WORKDIR /go/src/service
ADD . .
RUN CGO_LDFLAGS="-static" CGO_ENABLED=1 GOOS=linux go build
FROM alpine
WORKDIR /root
COPY --from=builder /go/src/service /root
Run
docker run -it facerecognize:latest /root/service
Nayoung
One restriction here user app should be in GOPATH to re-use go-face package.
I hope this will help someone.
from go-face.
Hello @tpoxa ,
Thanks for your research with Docker.
Reproducing what you've done and fixing little issues I reached to have the example program running in the container (using go run
).
Still, I'm fighting with an issue when trying to build the binary
using CGO_LDFLAGS="-static" CGO_ENABLED=1 GOOS=linux go build
Does the following error is bringing some bells to you?
(.text+0x9cd): undefined reference to `_gfortran_concat_string'
from go-face.
(.text+0x781): more undefined references to
_gfortran_concat_string' follow
collect2`
i have the same error
from go-face.
I've managed to build static binary with dlib with such a Dockerfile
and reduced ldflags in face.go
.
// #cgo LDFLAGS: -ldlib
import "C"
https://github.com/vearutop/faces/blob/v0.1.4/vendor/github.com/Kagami/go-face/face_static.go
FROM ubuntu:22.04 as builder
RUN apt-get update
RUN apt-get install -y build-essential cmake curl
RUN curl -sLO https://go.dev/dl/go1.21.6.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz && rm -rf go1.21.6.linux-amd64.tar.gz
RUN mkdir /dlib && cd /dlib && curl -sLO http://dlib.net/files/dlib-19.24.tar.bz2 && tar xf dlib-19.24.tar.bz2
RUN cd /dlib/dlib-19.24 && mkdir build && cd build && cmake .. && cmake --build . --config Release && make install && rm -rf /dlib
# Missing header file.
RUN cp /usr/local/include/dlib/external/libjpeg/*.h /usr/include/
# Building app.
WORKDIR /app
ADD . .
RUN CGO_LDFLAGS="-static" /usr/local/go/bin/go build -tags static .
# Exporting minimal docker image with pre-built binary.
FROM alpine
WORKDIR /root
CMD ["/bin/faces", "-listen", "0.0.0.0:80"]
COPY --from=builder /app/faces /bin/faces
More info in a blog post.
from go-face.
Related Issues (20)
- windows run : running g++ failed: exit status 1 cannot find -lblas: No such file or directory HOT 5
- How to use a face detection model with 68 feature points.
- library not work with AWS Lambda ECR
- openblas is installed on WIN10, but I still get undefined reference to `cblas_sgemm'
- Error recognizing unclassified faces.
- go get issue in ubuntu 20.04 HOT 1
- face alignment HOT 1
- Issue with go get on M1 MacOS HOT 6
- issu with install
- how to save model and load it later?
- How does Centos install dlib?
- does go face support docker or not HOT 2
- Face matching
- There is a problem, please help to look at it HOT 9
- Find similar faces?
- Option to ignore a specific folder
- SIGILL: illegal instruction HOT 5
- Opencv Image buffer
- cant run functions ("undefined 1.2"), need to update face.go? HOT 9
- got error "jpeg_mem_loader: unsupported pixel size"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-face.