Skip to content

Instantly share code, notes, and snippets.

@Ottovsky
Created May 11, 2020 14:07
Show Gist options
  • Save Ottovsky/8e689a1bcc11b312c2c025d1fb74c097 to your computer and use it in GitHub Desktop.
Save Ottovsky/8e689a1bcc11b312c2c025d1fb74c097 to your computer and use it in GitHub Desktop.
gitlab-runner docker image for armv7
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"]
@Ottovsky
Copy link
Author

Ottovsky commented May 11, 2020

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:

gitlabUrl: https://gitlab.com/
runnerRegistrationToken: "registration-token"
image: ottovsky/gitlab-runner:armv7
concurrent: 10
checkInterval: 30
rbac:
  create: true
  clusterWideAccess: false
runners:
  image: ubuntu:18.04
  privileged: true
  builds:
    cpuRequests: 100m
    memoryRequests: 128Mi
  services:
    cpuRequests: 500m
    memoryRequests: 512Mi
  helpers: 
    cpuLimit: 2
    memoryLimit: 2048Mi
    cpuRequests: 100m
    memoryRequests: 128Mi
    image: gitlab/gitlab-runner-helper:arm-latest
    nodeSelector:
      kubernetes.io/arch: arm
nodeSelector: 
    kubernetes.io/arch: arm

ottovsky/gitlab-runner:armv7 is using gitlab-runner version 12.10.1

@demaniak
Copy link

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

@demaniak
Copy link

demaniak commented Mar 2, 2022

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

@Ottovsky
Copy link
Author

Ottovsky commented Mar 3, 2022

Thank you for the update! It has been a while when I was playing with gitlab-runners on arm :)

@schnitzlein
Copy link

cool Thing, thanks! 👍 :)

@CaseyRo
Copy link

CaseyRo commented Jul 22, 2022

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