Skip to content

Commit

Permalink
Merge pull request #18 from lemeurherve/fix-mirrorbits-arm64
Browse files Browse the repository at this point in the history
feat: build `mirrorbits` with Golang `1.23.0` in the image to get an arm64 binary
  • Loading branch information
dduportal authored Aug 20, 2024
2 parents 0cb24be + a343ef6 commit c09f2d8
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
FROM debian:stable-slim AS mirrorbits
FROM golang:1.23.0 AS build

## (DL3008)Ignore lint error about apt pinned packages, as we always want the latest version of these tools
## and the risk of a breaking behavior is evaluated as low
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install --no-install-recommends -y tar curl ca-certificates && \
RUN apt-get -qq update && \
apt-get install --no-install-recommends -y libgeoip-dev tar curl ca-certificates git unzip zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ARG mirrorbits_version=v0.5.1
RUN mkdir /mirrorbits && \
curl -L https://github.com/etix/mirrorbits/releases/download/${mirrorbits_version}/mirrorbits-${mirrorbits_version}.tar.gz -O && \
tar xvzf /mirrorbits-${mirrorbits_version}.tar.gz -C /
# 955a8b2e1aacea1cae06396a64afbb531ceb36d4 introduced go modules (for Go >= 1.11) and commited the generated code from protoc
# v0.5.1 tag is a bit older (but without these 2 majors elements): https://github.com/etix/mirrorbits/commit/e83e56ac6496a3643d18a731324bd266f75f7b32 commit
# Diff: https://github.com/etix/mirrorbits/compare/e83e56ac6496a3643d18a731324bd266f75f7b32..955a8b2e1aacea1cae06396a64afbb531ceb36d4
ARG mirrorbits_version=955a8b2e1aacea1cae06396a64afbb531ceb36d4

ARG tini_version=v0.19.0
RUN curl --silent --show-error --output /mirrorbits/tini --location \
"https://github.com/krallin/tini/releases/download/${tini_version}/tini-$(dpkg --print-architecture)" && \
chmod +x /mirrorbits/tini
WORKDIR "/mirrorbits"

FROM debian:stable-slim
# hadolint ignore=DL3003
RUN git clone https://github.com/etix/mirrorbits ./ && \
git checkout "${mirrorbits_version}"

EXPOSE 8080
# Do not call parent target (dependencies are vendorized) but we still want the proper LDFLAGS
RUN sed -i 's/^build:.*/build:/g' Makefile && \
make build

ARG tini_version=v0.19.0
ARG mirrorbits_version=v0.5.1
RUN curl --silent --show-error --output ./tini --location \
"https://github.com/krallin/tini/releases/download/${tini_version}/tini-$(dpkg --print-architecture)" && \
chmod a+x ./tini

LABEL repository="https://github.com/olblak/mirrorbits"
FROM debian:stable-slim AS mirrorbits

# Repeat ARGS for labels
ARG tini_version=v0.19.0
ARG mirrorbits_version=955a8b2e1aacea1cae06396a64afbb531ceb36d4

## (DL3008)Ignore lint error about apt pinned packages, as we always want the latest version of these tools
## and the risk of a breaking behavior is evaluated as low
Expand All @@ -51,15 +58,17 @@ USER mirrorbits

COPY config/mirrorbits.conf /etc/mirrorbits/mirrorbits.conf

COPY --from=mirrorbits /mirrorbits/tini /bin/tini

COPY --from=mirrorbits /mirrorbits/mirrorbits /usr/bin/mirrorbits
COPY --from=build /mirrorbits/tini /bin/tini
COPY --from=build /mirrorbits/bin/mirrorbits /usr/bin/mirrorbits
COPY --from=build /mirrorbits/templates /usr/share/mirrorbits/templates

COPY --from=mirrorbits /mirrorbits/templates /usr/share/mirrorbits/templates
LABEL \
io.jenkins-infra.tools="mirrorbits,tini" \
io.jenkins-infra.tools.mirrorbits.version="${mirrorbits_version}" \
io.jenkins-infra.tools.tini.version="${tini_version}" \
repository="https://github.com/jenkins-infra/docker-mirrorbits"

LABEL io.jenkins-infra.tools="mirrorbits,tini"
LABEL io.jenkins-infra.tools.mirrorbits.version="${mirrorbits_version}"
LABEL io.jenkins-infra.tools.tini.version="${tini_version}"
EXPOSE 8080 3390

ENTRYPOINT [ "/bin/tini","--" ]

Expand Down

0 comments on commit c09f2d8

Please sign in to comment.