Gitea ARM crossbuild
Instead of building the Gitea binary on a Raspberry PI, we can speed up things a bit by crossbuilding from some other computer with more punch. Recent version of Gitea will need nodejs/npm to be available at build time, so we’ll install this too.
Dockerfile sample:
FROM golang:latest
RUN dpkg --add-architecture armhf
RUN apt-get update
RUN apt-get install -y --no-install-recommends curl git build-essential crossbuild-essential-armhf
SHELL [ "/bin/bash", "--login", "-c" ]
ARG NVM_VERSION="0.37.2"
RUN\
( export PROFILE=$HOME/.profile;\
/usr/bin/curl -o- "https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh" | /bin/bash )
ARG NODE_VERSION="14.15.3"
RUN\
nvm install "${NODE_VERSION}" &&\
nvm use "v${NODE_VERSION}" &&\
nvm alias default "v${NODE_VERSION}"
ARG YARN_VERSION="1.22.10"
RUN\
( export PROFILE=$HOME/.profile;\
/usr/bin/curl -o- -L "https:/yarnpkg.com/install.sh" | /bin/bash -s -- --version ${YARN_VERSION})
RUN\
( echo ;\
echo 'source $HOME/.nvm/nvm.sh';\
echo 'export PATH=/go/bin:/usr/local/go/bin:${PATH}'; ) >> $HOME/.profile
WORKDIR /go
ENV GOARM=7
ENV GOARCH=arm
ENV GOOS=linux
ARG GITEA_VERSION="v1.12.6"
RUN go get -d -u code.gitea.io/gitea
RUN cd /go/src/code.gitea.io/gitea && git checkout ${GITEA_VERSION}
RUN cd /go/src/code.gitea.io/gitea && TAGS="bindata sqlite sqlite_unlock_notify" make build
Which we can run with (replace the host_output_dir with some folder on the host):
docker build -t gitea-arm-builder .
docker run --rm -v [host_output_dir]:/output gitea-arm-builder cp /go/src/code.gitea.io/gitea/gitea /output/gitea-1.12.5-arm-linux
My real setup is a little bit more involved as it uses Docker-Compose and multi-staged Dockerfiles to share the nodejs install and optimize the build.