Я пытаюсь использовать GitlabCI для создания бинарного файла Go для ArmV7l.
После нескольких неудачных намерений я мог бы успешно скомпилировать его с этим .gitlab-ci.yml
image: golang
variables:
PACKAGE_PATH: /go/src/gitlab.com/company/edge_to_bc
PACKAGE_API_NAME: registry.gitlab.com/company/edge_to_bc
REGISTRY_URL: https://registry.gitlab.com
DOCKER_DRIVER: overlay
stages:
- build
- publish
# A hack to make Golang-in-Gitlab happy
.anchors:
- &inject-gopath
mkdir -p $(dirname ${PACKAGE_PATH})
&& ln -s ${CI_PROJECT_DIR} ${PACKAGE_PATH}
&& cd ${PACKAGE_PATH}
# ==================== TEST ====================
build_binary:
stage: build
before_script:
- *inject-gopath
- dpkg --add-architecture armhf
- apt update && apt-get install -y gcc-arm-linux-gnueabihf libltdl-dev:armhf
script:
- CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build -v -o ./release/edge_to_bc
artifacts:
name: "binary-$CI_PIPELINE_ID"
paths:
- release/edge_to_bc
expire_in: 1 hour
docker-push:
stage: publish
before_script:
- *inject-gopath
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY_URL
image: docker:stable
services:
- docker:dind
script:
- docker build -t $PACKAGE_API_NAME:$CI_BUILD_ID .
- docker build -t $PACKAGE_API_NAME:latest .
- docker push $PACKAGE_API_NAME:$CI_BUILD_ID
- docker push $PACKAGE_API_NAME:latest
dependencies:
- build_binary
Здесьмой Dockerfile.
FROM alpine:3.7
RUN apk --no-cache add ca-certificates libtool
WORKDIR /sunclient/
COPY ./release/edge_to_bc /sunclient/
EXPOSE 5555
CMD [ "./edge_to_bc" ]
Когда я запускаю его на своей плате ARM, я получаю:
[root@artik system]# docker run -it registry.gitlab.com/company/edge_to_bc:latest bash
standard_init_linux.go:207: exec user process caused "exec format error"
Когда я хочу отладить его, с помощью bash:
[root@artik system]# docker run registry.gitlab.com/company/edge_to_bc:latest
standard_init_linux.go:207: exec user process caused "no such file or directory"
Что мне делать?