Created
May 11, 2020 14:07
-
-
Save Ottovsky/8e689a1bcc11b312c2c025d1fb74c097 to your computer and use it in GitHub Desktop.
gitlab-runner docker image for armv7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.13.9-alpine3.11 as build | |
ARG GIT_LFS_VERSION | |
RUN mkdir -p src/github.com/git-lfs/git-lfs && \ | |
wget -nv -O /tmp/git-lfs.tar.gz https://github.com/git-lfs/git-lfs/archive/v${GIT_LFS_VERSION}.tar.gz && \ | |
tar xf /tmp/git-lfs.tar.gz -C src/github.com/git-lfs/git-lfs --strip-components 1 && \ | |
GOARCH=arm GOOS=linux GOARM_VERSION=7 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o bin/git-lfs github.com/git-lfs/git-lfs/ | |
FROM arm32v7/alpine:3.10 | |
RUN adduser -D -S -h /home/gitlab-runner gitlab-runner | |
RUN apk add --no-cache \ | |
bash \ | |
ca-certificates \ | |
git \ | |
openssl \ | |
tzdata \ | |
wget | |
ARG DOCKER_MACHINE_VERSION | |
ARG TINI_VERSION | |
ARG GITLAB_RUNNER_VERSION | |
COPY --from=build /go/bin/git-lfs /usr/bin/git-lfs | |
RUN wget -nv "https://gitlab-runner-downloads.s3.amazonaws.com/v${GITLAB_RUNNER_VERSION}/binaries/gitlab-runner-linux-arm" -O /usr/bin/gitlab-runner && \ | |
chmod +x /usr/bin/gitlab-runner && \ | |
chmod +x /usr/bin/git-lfs && \ | |
ln -s /usr/bin/gitlab-runner /usr/bin/gitlab-ci-multi-runner && \ | |
gitlab-runner --version && \ | |
mkdir -p /etc/gitlab-runner/certs && \ | |
chmod -R 700 /etc/gitlab-runner && \ | |
wget -nv "https://github.com/docker/machine/releases/download/v${DOCKER_MACHINE_VERSION}/docker-machine-Linux-armhf" -O /usr/bin/docker-machine && \ | |
chmod +x /usr/bin/docker-machine && \ | |
docker-machine --version && \ | |
wget -nv "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-armhf" -O /usr/bin/tini && \ | |
chmod +x /usr/bin/tini && \ | |
tini --version && \ | |
git-lfs install --skip-repo && \ | |
git-lfs version | |
RUN wget -nv "https://gitlab.com/gitlab-org/gitlab-runner/-/raw/v${GITLAB_RUNNER_VERSION}/dockerfiles/alpine/entrypoint" -O /entrypoint && \ | |
chmod +x /entrypoint | |
STOPSIGNAL SIGQUIT | |
VOLUME ["/etc/gitlab-runner", "/home/gitlab-runner"] | |
ENTRYPOINT ["/usr/bin/tini","--", "/entrypoint"] | |
CMD ["run", "--user=gitlab-runner", "--working-directory=/home/gitlab-runner"] |
Thanks for this @Ottovsky !
For people trying to build this locally, this worked for me (11 November 2021):
- dump the above gist contents into a
Dockerfile
- Then run
docker build -t gitlab-runner-armv7 --build-arg GIT_LFS_VERSION=3.0.2 --build-arg GITLAB_RUNNER_VERSION=12.10.1 --build-arg DOCKER_MACHINE_VERSION=0.16.2 --build-arg TINI_VERSION=0.19.0 .
- verify it's working:
docker run --rm -it gitlab-runner-armv7 --help
For runner version 14.7.1, use Docker file as so (the entrypoint file location moved, rest is the same as above):
FROM golang:1.13.9-alpine3.11 as build
ARG GIT_LFS_VERSION
#RUN mkdir -p src/github.com/git-lfs/git-lfs && \
#wget -nv -O /tmp/git-lfs.tar.gz https://github.com/git-lfs/git-lfs/archive/v${GIT_LFS_VERSION}.tar.gz && \
#tar xf /tmp/git-lfs.tar.gz -C src/github.com/git-lfs/git-lfs --strip-components 1 && \
#GOARCH=arm GOOS=linux GOARM_VERSION=7 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o bin/git-lfs github.com/git-lfs/git-lfs/
RUN mkdir -p src/github.com/git-lfs/git-lfs
RUN wget -nv -O /tmp/git-lfs.tar.gz https://github.com/git-lfs/git-lfs/archive/v${GIT_LFS_VERSION}.tar.gz
RUN tar xf /tmp/git-lfs.tar.gz -C src/github.com/git-lfs/git-lfs --strip-components 1
RUN GOARCH=arm GOOS=linux GOARM_VERSION=7 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o bin/git-lfs github.com/git-lfs/git-lfs/
FROM arm32v7/alpine:3.10
RUN adduser -D -S -h /home/gitlab-runner gitlab-runner
RUN apk add --no-cache \
bash \
ca-certificates \
git \
openssl \
tzdata \
wget
ARG DOCKER_MACHINE_VERSION
ARG TINI_VERSION
ARG GITLAB_RUNNER_VERSION
COPY --from=build /go/bin/git-lfs /usr/bin/git-lfs
RUN wget -nv "https://gitlab-runner-downloads.s3.amazonaws.com/v${GITLAB_RUNNER_VERSION}/binaries/gitlab-runner-linux-arm" -O /usr/bin/gitlab-runner && \
chmod +x /usr/bin/gitlab-runner && \
chmod +x /usr/bin/git-lfs && \
ln -s /usr/bin/gitlab-runner /usr/bin/gitlab-ci-multi-runner && \
gitlab-runner --version && \
mkdir -p /etc/gitlab-runner/certs && \
chmod -R 700 /etc/gitlab-runner && \
wget -nv "https://github.com/docker/machine/releases/download/v${DOCKER_MACHINE_VERSION}/docker-machine-Linux-armhf" -O /usr/bin/docker-machine && \
chmod +x /usr/bin/docker-machine && \
docker-machine --version && \
wget -nv "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-armhf" -O /usr/bin/tini && \
chmod +x /usr/bin/tini && \
tini --version && \
git-lfs install --skip-repo && \
git-lfs version
RUN wget -nv "https://gitlab.com/gitlab-org/gitlab-runner/-/raw/v${GITLAB_RUNNER_VERSION}/dockerfiles/runner/alpine/entrypoint" -O /entrypoint && \
chmod +x /entrypoint
STOPSIGNAL SIGQUIT
VOLUME ["/etc/gitlab-runner", "/home/gitlab-runner"]
ENTRYPOINT ["/usr/bin/tini","--", "/entrypoint"]
CMD ["run", "--user=gitlab-runner", "--working-directory=/home/gitlab-runner"]
Build with a script like so:
#!/bin/bash
RUNNER_VERSION="14.7.1"
docker build -f Dockerfile-$RUNNER_VERSION -t gitlab-runner-armv7 --build-arg GIT_LFS_VERSION=3.0.2 --build-arg GITLAB_RUNNER_VERSION=$RUNNER_VERSION --build-arg DOCKER_MACHINE_VERSION=0.16.2 --build-arg TINI_VERSION=0.19.0 .
And run/upgrade with script like:
#!/bin/bash
RUNNER_NAME=gitlab-runner
docker container stop $RUNNER_NAME
docker container rm $RUNNER_NAME
docker run -d --name $RUNNER_NAME --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v gitlab-runner-config:/etc/gitlab-runner \
gitlab-runner-armv7:latest
Thank you for the update! It has been a while when I was playing with gitlab-runners on arm :)
cool Thing, thanks! 👍 :)
thanks @demaniak ! helped me get my Pies doing some work!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't find anywhere an armv7 working image of gitlab-runner, so here is one. This image can be used with raspberry pi 4. It can be installed in the k8s cluster by using standard helm installation:
helm upgrade --install --namespace gitlab-ci gitlab-runner -f values.yaml gitlab/gitlab-runner
.Where
value.yaml
:ottovsky/gitlab-runner:armv7
is using gitlab-runner version 12.10.1