I have a problem with building a Go code which uses C. The idea is to build a binary inside the docker container and then create a slim docker image with that binary. Everything works fine for services which don't contain C code. I can run binary inside docker containers or on the host machine. But I can't run binary with C code neither inside the container nor on the host machine. I always encounter the following error: No such file or directory
. I set the env variables CGO_ENABLED=1 GOOS=linux GOARCH=amd64. Can someone please tell me where the issue is? Thanks.
Dockerfile for $IMAGE
FROM golang:1.13-alpine
ARG PKG_CONFIG_PATH=/usr/local/ffmpeg/pkgconfig
RUN apk update \
&& apk add \
git \
ffmpeg-dev \
gcc \
libc-dev \
pkgconfig \
&& rm -rf /var/cache/apk/*
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.24.0
Command
docker run --rm -it -v $PWD:/go/src/project -w /go/src/project/api \
--env CGO_ENABLED=1 --env GOOS=linux --env GOARCH=amd64 \
$IMAGE go build -a -installsuffix cgo -o ../bin/api/api