Skip to content

Commit 013d638

Browse files
authored
Merge pull request #81 from AkihiroSuda/dev
Add "full" distribution
2 parents 1666cda + 8cd78d9 commit 013d638

File tree

6 files changed

+153
-31
lines changed

6 files changed

+153
-31
lines changed

.dockerignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# artifacts
2+
/nerdctl
3+
_output
4+
5+
# golangci-lint
6+
build
7+
8+
# vagrant
9+
/.vagrant

.github/workflows/release.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ jobs:
3333
run: |
3434
tag="${GITHUB_REF##*/}"
3535
shasha=$(sha256sum _output/SHA256SUMS | awk '{print $1}')
36-
cat << EOF | tee /tmp/release-note.txt
36+
cat <<-EOF | tee /tmp/release-note.txt
3737
${tag}
3838
39-
#### Changes
40-
(To be documented)
41-
42-
#### About the binaries
39+
$(hack/generate-release-note.sh)
40+
- - -
4341
The binaries were built automatically on GitHub Actions.
4442
The build log is available for 90 days: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
4543

Dockerfile

+72-25
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,79 @@
11
# Usage: `docker run -it --privileged <IMAGE>`. Make sure to add `-t` and `--privileged`.
2-
ARG UBUNTU_VERSION=20.04
3-
ARG CONTAINERIZED_SYSTEMD_VERSION=0.1.1
2+
3+
# Basic deps
44
ARG CONTAINERD_VERSION=1.5.0-beta.2
55
ARG RUNC_VERSION=1.0.0-rc93
66
ARG CNI_PLUGINS_VERSION=0.9.1
7+
8+
# Extra deps: CNI isolation
79
ARG CNI_ISOLATION_VERSION=0.0.3
10+
# Extra deps: Build
811
ARG BUILDKIT_VERSION=0.8.2
12+
# Extra deps: Lazy-pulling
13+
ARG STARGZ_SNAPSHOTTER_VERSION=0.4.1
14+
# Extra deps: Rootless
15+
ARG ROOTLESSKIT_VERSION=0.14.0-beta.0
16+
ARG SLIRP4NETNS_VERSION=1.1.9
17+
18+
# Test deps
919
ARG GO_VERSION=1.16
20+
ARG UBUNTU_VERSION=20.04
21+
ARG CONTAINERIZED_SYSTEMD_VERSION=0.1.1
22+
23+
FROM golang:${GO_VERSION}-alpine AS build-minimal
24+
RUN apk add --no-cache make git
25+
COPY . /go/src/github.com/AkihiroSuda/nerdctl
26+
WORKDIR /go/src/github.com/AkihiroSuda/nerdctl
27+
RUN BINDIR=/out/bin make binaries install
28+
# We do not set CMD to `go test` here, because it requires systemd
29+
30+
FROM build-minimal AS build-full
31+
RUN apk add --no-cache curl
32+
RUN mkdir -p /out/share/doc/nerdctl-full && \
33+
echo "# nerdctl (full distribution)" > /out/share/doc/nerdctl-full/README.md && \
34+
echo "- nerdctl: $(cd /go/src/github.com/AkihiroSuda/nerdctl && git describe --tags)" >> /out/share/doc/nerdctl-full/README.md
35+
ARG TARGETARCH
36+
ARG CONTAINERD_VERSION
37+
RUN curl -L https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/containerd-${CONTAINERD_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /out && \
38+
rm -f /out/bin/containerd-shim /out/bin/containerd-shim-runc-v1 && \
39+
echo "- containerd: v${CONTAINERD_VERSION}" >> /out/share/doc/nerdctl-full/README.md
40+
ARG RUNC_VERSION
41+
RUN curl -L -o /out/bin/runc https://github.com/opencontainers/runc/releases/download/v${RUNC_VERSION}/runc.${TARGETARCH:-amd64} && \
42+
chmod +x /out/bin/runc && \
43+
echo "- runc: v${RUNC_VERSION}" >> /out/share/doc/nerdctl-full/README.md
44+
ARG CNI_PLUGINS_VERSION
45+
RUN mkdir -p /out/libexec/cni && \
46+
curl -L https://github.com/containernetworking/plugins/releases/download/v${CNI_PLUGINS_VERSION}/cni-plugins-linux-${TARGETARCH:-amd64}-v${CNI_PLUGINS_VERSION}.tgz | tar xzvC /out/libexec/cni && \
47+
echo "- CNI plugins: v${CNI_PLUGINS_VERSION}" >> /out/share/doc/nerdctl-full/README.md
48+
ARG CNI_ISOLATION_VERSION
49+
RUN curl -L https://github.com/AkihiroSuda/cni-isolation/releases/download/v${CNI_ISOLATION_VERSION}/cni-isolation-${TARGETARCH:-amd64}.tgz | tar xzvC /out/libexec/cni && \
50+
echo "- CNI isolation plugin: v${CNI_ISOLATION_VERSION}" >> /out/share/doc/nerdctl-full/README.md
51+
ARG BUILDKIT_VERSION
52+
RUN curl -L https://github.com/moby/buildkit/releases/download/v${BUILDKIT_VERSION}/buildkit-v${BUILDKIT_VERSION}.linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /out && \
53+
rm -f /out/bin/buildkit-qemu-* /out/bin/buildkit-runc && \
54+
echo "- BuildKit: v${BUILDKIT_VERSION}" >> /out/share/doc/nerdctl-full/README.md
55+
ARG STARGZ_SNAPSHOTTER_VERSION
56+
RUN curl -L https://github.com/containerd/stargz-snapshotter/releases/download/v${STARGZ_SNAPSHOTTER_VERSION}/stargz-snapshotter-v${STARGZ_SNAPSHOTTER_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /out/bin && \
57+
echo "- Stargz Snapshotter: v${STARGZ_SNAPSHOTTER_VERSION}" >> /out/share/doc/nerdctl-full/README.md
58+
ARG ROOTLESSKIT_VERSION
59+
RUN curl -L https://github.com/rootless-containers/rootlesskit/releases/download/v${ROOTLESSKIT_VERSION}/rootlesskit-$(uname -m).tar.gz | tar xzvC /out/bin && \
60+
rm -f /out/bin/rootlesskit-docker-proxy && \
61+
echo "- RootlessKit: v${ROOTLESSKIT_VERSION}" >> /out/share/doc/nerdctl-full/README.md
62+
ARG SLIRP4NETNS_VERSION
63+
RUN curl -L -o /out/bin/slirp4netns https://github.com/rootless-containers/slirp4netns/releases/download/v${SLIRP4NETNS_VERSION}/slirp4netns-$(uname -m) && \
64+
chmod +x /out/bin/slirp4netns && \
65+
echo "- slirp4netns: v${SLIRP4NETNS_VERSION}" >> /out/share/doc/nerdctl-full/README.md
66+
RUN echo "" >> /out/share/doc/nerdctl-full/README.md && \
67+
echo "## License" >> /out/share/doc/nerdctl-full/README.md && \
68+
echo "- bin/slirp4netns: [GNU GENERAL PUBLIC LICENSE, Version 2](https://github.com/rootless-containers/slirp4netns/blob/v${SLIRP4NETNS_VERSION}/COPYING)" >> /out/share/doc/nerdctl-full/README.md && \
69+
echo "- Other files: [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)" >> /out/share/doc/nerdctl-full/README.md
70+
RUN (cd /out && find ! -type d | sort | xargs sha256sum > /tmp/SHA256SUMS ) && \
71+
mv /tmp/SHA256SUMS /out/share/doc/nerdctl-full/SHA256SUMS
72+
73+
FROM scratch AS out-full
74+
COPY --from=build-full /out /
1075

11-
FROM mirror.gcr.io/library/ubuntu:${UBUNTU_VERSION} AS base
12-
ENV DEBIAN_FRONTEND=noninteractive
76+
FROM ubuntu:${UBUNTU_VERSION} AS base
1377
RUN apt-get update && \
1478
apt-get install -qq -y --no-install-recommends \
1579
ca-certificates curl \
@@ -18,26 +82,11 @@ RUN apt-get update && \
1882
ARG CONTAINERIZED_SYSTEMD_VERSION
1983
RUN curl -L -o /docker-entrypoint.sh https://raw.githubusercontent.com/AkihiroSuda/containerized-systemd/v${CONTAINERIZED_SYSTEMD_VERSION}/docker-entrypoint.sh && \
2084
chmod +x /docker-entrypoint.sh
21-
ARG CONTAINERD_VERSION
22-
ARG TARGETARCH
23-
RUN curl -L https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/containerd-${CONTAINERD_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /usr/local && \
24-
rm -f /usr/local/bin/containerd-{shim,shim-runc-v1}
25-
COPY Dockerfile.d/containerd.service /etc/systemd/system/containerd.service
26-
RUN systemctl enable containerd
27-
ARG RUNC_VERSION
28-
RUN curl -L -o /usr/local/sbin/runc https://github.com/opencontainers/runc/releases/download/v${RUNC_VERSION}/runc.${TARGETARCH:-amd64} && \
29-
chmod +x /usr/local/sbin/runc
30-
ARG CNI_PLUGINS_VERSION
31-
RUN mkdir -p /opt/cni/bin && \
32-
curl -L https://github.com/containernetworking/plugins/releases/download/v${CNI_PLUGINS_VERSION}/cni-plugins-linux-${TARGETARCH:-amd64}-v${CNI_PLUGINS_VERSION}.tgz | tar xzvC /opt/cni/bin
33-
ARG CNI_ISOLATION_VERSION
34-
RUN curl -L https://github.com/AkihiroSuda/cni-isolation/releases/download/v${CNI_ISOLATION_VERSION}/cni-isolation-${TARGETARCH:-amd64}.tgz | tar xzvC /opt/cni/bin
35-
ARG BUILDKIT_VERSION
36-
RUN curl -L https://github.com/moby/buildkit/releases/download/v${BUILDKIT_VERSION}/buildkit-v${BUILDKIT_VERSION}.linux-${TARGETARCH:-amd64}.tar.gz | tar xzvC /usr/local && \
37-
rm -f /usr/local/bin/buildkit-qemu-* /usr/local/bin/buildkit-runc
38-
COPY Dockerfile.d/buildkitd.service /etc/systemd/system/buildkitd.service
39-
RUN systemctl enable buildkitd
85+
COPY --from=out-full / /usr/local/
86+
COPY Dockerfile.d/*.service /etc/systemd/system
87+
RUN systemctl enable containerd buildkitd
4088
VOLUME /var/lib/containerd
89+
VOLUME /var/lib/buildkit
4190
VOLUME /var/lib/nerdctl
4291
ENTRYPOINT ["/docker-entrypoint.sh"]
4392
CMD ["bash"]
@@ -53,8 +102,6 @@ ENV PATH=/usr/local/go/bin:$PATH
53102
COPY . /go/src/github.com/AkihiroSuda/nerdctl
54103
WORKDIR /go/src/github.com/AkihiroSuda/nerdctl
55104
ENV CGO_ENABLED=0
56-
RUN make binaries install
57105
CMD ["go", "test", "-v", "./..."]
58106

59107
FROM base AS demo
60-
COPY --from=test /usr/local/bin/nerdctl /usr/local/bin

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ artifacts: clean
6262
GOOS=linux GOARCH=arm GOARM=7 make -C $(CURDIR) binaries
6363
tar $(TAR_FLAGS) -czvf $(CURDIR)/_output/nerdctl-$(VERSION_TRIMMED)-linux-arm-v7.tar.gz _output/nerdctl extras/rootless/*
6464

65-
rm -f _output/nerdctl
65+
rm -f $(CURDIR)/_output/nerdctl
66+
67+
DOCKER_BUILDKIT=1 docker build --output type=tar,dest=$(CURDIR)/_output/nerdctl-full-$(VERSION_TRIMMED)-linux-amd64.tar --target out-full $(CURDIR)
68+
gzip -9 $(CURDIR)/_output/nerdctl-full-$(VERSION_TRIMMED)-linux-amd64.tar
6669

6770
.PHONY: \
6871
help \

hack/generate-release-note.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
minimal_amd64tgz="$(find _output -name '*amd64.tar.gz*' -and ! -name '*full*')"
3+
full_amd64tgz="$(find _output -name '*amd64.tar.gz*' -and -name '*full*')"
4+
5+
minimal_amd64tgz_basename="$(basename ${minimal_amd64tgz})"
6+
full_amd64tgz_basename="$(basename ${full_amd64tgz})"
7+
8+
cat <<-EOX
9+
## Changes
10+
(To be documented)
11+
12+
## About the binaries
13+
- Minimal (\`${minimal_amd64tgz_basename}\`): nerdctl only
14+
- Full (\`${full_amd64tgz_basename}\`): Includes dependencies such as containerd, runc, and CNI
15+
16+
### Minimal
17+
Extract the archive to a path like \`/usr/local/bin\` or \`~/bin\` .
18+
<details><summary>tar Cxzvvf /usr/local/bin ${minimal_amd64tgz_basename}</summary>
19+
<p>
20+
21+
\`\`\`
22+
$(tar tzvf ${minimal_amd64tgz})
23+
\`\`\`
24+
</p>
25+
</details>
26+
27+
### Full
28+
Extract the archive to a path like \`/usr/local\` or \`~/.local\` .
29+
30+
<details><summary>tar Cxzvvf /usr/local ${full_amd64tgz_basename}</summary>
31+
<p>
32+
33+
\`\`\`
34+
$(tar tzvf ${full_amd64tgz})
35+
\`\`\`
36+
</p>
37+
</details>
38+
39+
<details><summary>Included components</summary>
40+
<p>
41+
42+
See \`share/doc/nerdctl-full/README.md\`:
43+
\`\`\`markdown
44+
$(tar xOzf ${full_amd64tgz} share/doc/nerdctl-full/README.md)
45+
\`\`\`
46+
</p>
47+
</details>
48+
49+
## Quick start
50+
### Rootful
51+
\`\`\`console
52+
$ sudo systemctl enable --now containerd
53+
$ sudo nerdctl run -d --name nginx -p 80:80 nginx:alpine
54+
\`\`\`
55+
56+
### Rootless
57+
\`\`\`console
58+
$ containerd-rootless-setuptool.sh install
59+
$ nerdctl run -d --name nginx -p 8080:80 nginx:alpine
60+
\`\`\`
61+
62+
Rootless mode requires systemd and cgroup v2, see https://rootlesscontaine.rs/getting-started/common/cgroup2/ .
63+
EOX

pkg/defaults/defaults.go

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func CNIPath() string {
5050
panic("environment variable HOME is not set")
5151
}
5252
candidates = append([]string{
53+
// NOTE: These user paths are not defined in XDG
54+
filepath.Join(home, ".local/libexec/cni"),
5355
filepath.Join(home, "opt/cni/bin"),
5456
}, candidates...)
5557
}

0 commit comments

Comments
 (0)