Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker example with FAQ #76

Open
romshark opened this issue Oct 16, 2021 · 0 comments
Open

Add Docker example with FAQ #76

romshark opened this issue Oct 16, 2021 · 0 comments

Comments

@romshark
Copy link

romshark commented Oct 16, 2021

I suggest adding a well documented Docker example to avoid the situation I faced today.
I was trying to build the example in the following Docker container:

FROM golang:1.17-bullseye

# Install go-face dependencies
RUN apt-get update && apt-get -y install \
    build-essentials \
    libdlib-dev \
    libblas-dev \
    libatlas-base-dev \
    liblapack-dev \
    libjpeg62-turbo-dev

# Build app
WORKDIR /app
COPY ./go.mod .
COPY ./go.sum .
COPY ./*.go .
COPY ./testdata/ testdata/
RUN go mod download
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -x -o app

CMD ["./app"]

But I wasn't able to build it. I received g++: fatal error: Killed signal terminated program cc1plus instead:

#13 [9/9] RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -x -o app
#13 sha256:231bad7fb338adee9a431ceebb81dd9089b9d33ad91e14cb252320b9c0476e4a
#13 0.237 WORK=/tmp/go-build3645608083
#13 0.599 mkdir -p $WORK/b038/
#13 0.600 cd /go/pkg/mod/github.com/!kagami/[email protected]
#13 0.600 TERM='dumb' CGO_LDFLAGS='"-g" "-O2" "-ldlib" "-lblas" "-lcblas" "-llapack" "-ljpeg"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b038/ -importpath github.com/Kagami/go-face -- -I $WORK/b038/ -g -O2 ./error.go ./face.go
#13 0.877 cd $WORK
#13 0.877 gcc -fno-caret-diagnostics -c -x c - -o /dev/null || true
#13 0.889 gcc -Qunused-arguments -c -x c - -o /dev/null || true
#13 0.898 gcc -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
#13 0.910 gcc -gno-record-gcc-switches -c -x c - -o /dev/null || true
#13 0.922 cd $WORK/b038
#13 0.922 TERM='dumb' gcc -I /go/pkg/mod/github.com/!kagami/[email protected] -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b038=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -o ./_x001.o -c _cgo_export.c
#13 0.975 TERM='dumb' gcc -I /go/pkg/mod/github.com/!kagami/[email protected] -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b038=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -o ./_x002.o -c error.cgo2.c
#13 1.006 TERM='dumb' gcc -I /go/pkg/mod/github.com/!kagami/[email protected] -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b038=/tmp/go-build -gno-record-gcc-switches -I ./ -g -O2 -o ./_x003.o -c face.cgo2.c
#13 1.052 cd $WORK
#13 1.052 g++ -fno-caret-diagnostics -c -x c - -o /dev/null || true
#13 1.064 g++ -Qunused-arguments -c -x c - -o /dev/null || true
#13 1.073 g++ -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true
#13 1.085 g++ -gno-record-gcc-switches -c -x c - -o /dev/null || true
#13 1.103 cd /go/pkg/mod/github.com/!kagami/[email protected]
#13 1.103 TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b038=/tmp/go-build -gno-record-gcc-switches -I $WORK/b038/ -g -O2 -std=c++1z -Wall -O3 -DNDEBUG -march=native -o $WORK/b038/_x004.o -c classify.cc
#13 3.309 TERM='dumb' g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/b038=/tmp/go-build -gno-record-gcc-switches -I $WORK/b038/ -g -O2 -std=c++1z -Wall -O3 -DNDEBUG -march=native -o $WORK/b038/_x005.o -c facerec.cc
#13 120.7 # github.com/Kagami/go-face
#13 120.7 g++: fatal error: Killed signal terminated program cc1plus
#13 120.7 compilation terminated.
#13 ERROR: executor failed running [/bin/sh -c CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -x -o app]: exit code: 2

Solution

The solution was actually quite simple. The compiler simply ran out of memory so I just needed to increase the default 2 GB ram limit of Docker for Mac to 4 GB. So I suggest adding this to the FAQ of the Docker example to save other people's time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant