Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build mirrorbits with Golang 1.23.0 in the image to get an arm64 binary #18

Merged
merged 5 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dduportal marked this conversation as resolved.
Show resolved Hide resolved

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 ./ && \
dduportal marked this conversation as resolved.
Show resolved Hide resolved
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
dduportal marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down