Skip to content

Commit d16f340

Browse files
authored
Merge pull request #4242 from AkihiroSuda/fix-4241
Dockerfile: fix cross-compiling gomodjail
2 parents 0b7f069 + 58a5fe0 commit d16f340

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/workflows/ghcr-image-build-and-publish.yml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- name: Checkout repository
3434
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3535

36+
# FIXME: setup-qemu-action is depended by `gomodjail pack`
3637
- name: Set up QEMU
3738
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
3839

.github/workflows/release.yml

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- 'v*'
77
- 'test-action-release-*'
8+
pull_request:
9+
paths-ignore:
10+
- '**.md'
811

912
env:
1013
GOTOOLCHAIN: local
@@ -21,6 +24,9 @@ jobs:
2124
attestations: write # for provenances
2225
steps:
2326
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
# FIXME: setup-qemu-action is depended by `gomodjail pack`
28+
- name: "Set up QEMU"
29+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
2430
- name: "Install go"
2531
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
2632
with:
@@ -53,6 +59,7 @@ jobs:
5359
with:
5460
subject-path: _output/*
5561
- name: "Create release"
62+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
5663
env:
5764
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5865
run: |

Dockerfile

+14-6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ ENV CGO_ENABLED=1
107107
RUN GO=xx-go make static && \
108108
xx-verify --static bypass4netns && cp -a bypass4netns bypass4netnsd /out/${TARGETARCH}
109109

110+
FROM build-base-debian AS build-gomodjail
111+
ARG GOMODJAIL_VERSION
112+
ARG TARGETARCH
113+
RUN git clone --quiet --depth 1 --branch "${GOMODJAIL_VERSION%@*}" https://github.com/AkihiroSuda/gomodjail.git /go/src/github.com/AkihiroSuda/gomodjail
114+
WORKDIR /go/src/github.com/AkihiroSuda/gomodjail
115+
RUN git-checkout-tag-with-hash.sh ${GOMODJAIL_VERSION} && \
116+
mkdir -p /out/${TARGETARCH}
117+
RUN GO=xx-go make STATIC=1 && \
118+
xx-verify --static _output/bin/gomodjail && cp -a _output/bin/gomodjail /out/${TARGETARCH}
119+
110120
FROM build-base-debian AS build-kubo
111121
ARG KUBO_VERSION
112122
ARG TARGETARCH
@@ -234,12 +244,8 @@ RUN ROOTLESSKIT_VERSION=${ROOTLESSKIT_VERSION/@BINARY}; \
234244
rm -f "${fname}" /out/bin/rootlesskit-docker-proxy && \
235245
echo "- RootlessKit: ${ROOTLESSKIT_VERSION}" >> /out/share/doc/nerdctl-full/README.md
236246
ARG GOMODJAIL_VERSION
237-
RUN git clone https://github.com/AkihiroSuda/gomodjail.git /go/src/github.com/AkihiroSuda/gomodjail && \
238-
cd /go/src/github.com/AkihiroSuda/gomodjail && \
239-
git-checkout-tag-with-hash.sh "${GOMODJAIL_VERSION}" && \
240-
make STATIC=1 && \
241-
cp -a _output/bin/gomodjail /out/bin/ && \
242-
echo "- gomodjail: ${GOMODJAIL_VERSION}" >> /out/share/doc/nerdctl-full/README.md
247+
COPY --from=build-gomodjail /out/${TARGETARCH:-amd64}/* /out/bin/
248+
RUN echo "- gomodjail: ${GOMODJAIL_VERSION}" >> /out/share/doc/nerdctl-full/README.md
243249

244250
RUN echo "" >> /out/share/doc/nerdctl-full/README.md && \
245251
echo "## License" >> /out/share/doc/nerdctl-full/README.md && \
@@ -254,6 +260,8 @@ COPY . /go/src/github.com/containerd/nerdctl
254260
RUN { echo "# nerdctl (full distribution)"; echo "- nerdctl: $(cd /go/src/github.com/containerd/nerdctl && git describe --tags)"; cat /out/share/doc/nerdctl-full/README.md; } > /out/share/doc/nerdctl-full/README.md.new; mv /out/share/doc/nerdctl-full/README.md.new /out/share/doc/nerdctl-full/README.md
255261
WORKDIR /go/src/github.com/containerd/nerdctl
256262
RUN BINDIR=/out/bin make binaries install
263+
# FIXME: `gomodjail pack` depends on QEMU for non-native architecture
264+
# TODO: gomodjail should provide a plain shell script that utilizes `zip(1)` for packing the self-extract archive, without running `gomodjail pack`..
257265
RUN /out/bin/gomodjail pack --go-mod=/go/src/github.com/containerd/nerdctl/go.mod /out/bin/nerdctl && \
258266
cp -a nerdctl.gomodjail /out/bin/
259267
COPY README.md /out/share/doc/nerdctl/

0 commit comments

Comments
 (0)