Skip to content

Commit 95ce638

Browse files
committed
Update Alpine base to 3.13; go-compile rebuilt with mod=vendor option, go bumped to 1.16
Signed-off-by: Avi Deitcher <[email protected]>
1 parent b13b41b commit 95ce638

10 files changed

+914
-862
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ Dockerfile.media
1919
*-cmdline
2020
*-state
2121
artifacts/*
22+
tools/alpine/iid

docs/releasing.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ other packages:
112112
cd $LK_ROOT/tools
113113
../scripts/update-component-sha.sh --image linuxkit/alpine:$LK_ALPINE
114114
git checkout alpine/versions.aarch64 alpine/versions.s390x
115+
git checkout grub/Dockerfile
115116

116117
git commit -a -s -m "tools: Update to the latest linuxkit/alpine"
117118
git push $LK_REMOTE rel_$LK_RELEASE
@@ -122,6 +123,8 @@ make forcepush
122123
Note, the `git checkout` reverts the changes made by
123124
`update-component-sha.sh` to files which are accidentally updated and
124125
the `make forcepush` will skip building the alpine base.
126+
Also, `git checkout` of `grub`. This is a bit old and only can be built with specific
127+
older versions of packages like `gcc`, and should not be updated.
125128

126129
Then, on the other build machines in turn:
127130

@@ -275,5 +278,3 @@ This completes the release, but you are not done, one more step is required.
275278
Create a PR which bumps the version number in the top-level `Makefile`
276279
to `$LK_RELEASE+` to make sure that the version reported by `linuxkit
277280
version` gets updated.
278-
279-

tools/alpine/Dockerfile

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.12 AS mirror
1+
FROM alpine:3.13 AS mirror
22

33
# update base image
44
RUN apk update && apk upgrade -a
@@ -7,11 +7,30 @@ RUN apk update && apk upgrade -a
77
COPY Dockerfile /Dockerfile
88
COPY packages* /tmp/
99

10-
# mirror packages
10+
# mirror packages - both generic and repository specific ones
1111
RUN cat /tmp/packages.$(uname -m) >> /tmp/packages && \
1212
mkdir -p /mirror/$(apk --print-arch) && \
1313
apk fetch --recursive -o /mirror/$(apk --print-arch) $(apk info; cat /tmp/packages)
1414

15+
# these are the repository-specific ones, if they exist
16+
RUN for repopkgs in /tmp/packages.repo.*; do \
17+
repo=${repopkgs##*repo.} && archspecific=/tmp/packages.$(uname -m).repo.${repo} && mergedfile=/tmp/packages.merged.${repo} && repofile=/tmp/repositories.${repo} && \
18+
cachedir=/tmp/cache/${repo} && \
19+
mkdir -p ${cachedir} && \
20+
cp ${repopkgs} ${mergedfile} && \
21+
if [ -f ${archspecific} ]; then cat ${archspecific} >> ${mergedfile}; fi && \
22+
sed "s#alpine/[^\/]*/#alpine/${repo}/#g" /etc/apk/repositories > ${repofile} && \
23+
apk update --repositories-file=${repofile} --cache-dir ${cachedir} && \
24+
apk fetch --repositories-file=${repofile} --cache-dir ${cachedir} --recursive -o /mirror/$(apk --print-arch) $(cat ${mergedfile}); done
25+
26+
# we CANNOT allow musl-dev or musl > 1.2.2-r0, which ships with alpine:3.13, because 1.2.2-r2, which ships with alpine:edge / alpine:3.14
27+
# uses the new faccessat2 system call which gives errors, see https://wiki.alpinelinux.org/wiki/Draft_Release_Notes_for_Alpine_3.14.0#faccessat2
28+
RUN target="1.2.2-r0" && \
29+
verlte() { [ "$1" = $(printf '%s\n%s' "$1" "$2" | sort -V | head -n1) ] ; } && \
30+
for file in /mirror/$(apk --print-arch)/musl-*.apk; do \
31+
version=$(tar -xf ${file} -O .PKGINFO | awk '$1 == "pkgver" {print $3}') && \
32+
if ! verlte ${version} ${target} ; then echo "removing ${file}" && rm ${file}; fi; done
33+
1534
# install abuild and sudo for signing
1635
RUN apk add --no-cache abuild sudo
1736

@@ -39,16 +58,18 @@ RUN go get -u github.com/LK4D4/vndr
3958
# checkout and compile containerd
4059
# Update `FROM` in `pkg/containerd/Dockerfile`, `pkg/init/Dockerfile` and
4160
# `test/pkg/containerd/Dockerfile` when changing this.
61+
# when building, note that containerd does not use go modules in the below commit,
62+
# while go1.16 defaults to using it, so must disable with GO111MODULE=off
4263
ENV CONTAINERD_REPO=https://github.com/containerd/containerd.git
43-
ENV CONTAINERD_COMMIT=v1.4.1
64+
ENV CONTAINERD_COMMIT=v1.4.4
4465
RUN mkdir -p $GOPATH/src/github.com/containerd && \
4566
cd $GOPATH/src/github.com/containerd && \
4667
git clone https://github.com/containerd/containerd.git && \
4768
cd $GOPATH/src/github.com/containerd/containerd && \
4869
git checkout $CONTAINERD_COMMIT
4970
RUN apk add --no-cache btrfs-progs-dev gcc libc-dev linux-headers make libseccomp-dev
5071
RUN cd $GOPATH/src/github.com/containerd/containerd && \
51-
make binaries EXTRA_FLAGS="-buildmode pie" EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' BUILDTAGS="static_build no_devmapper"
72+
GO111MODULE=off make binaries EXTRA_FLAGS="-buildmode pie" EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' BUILDTAGS="static_build no_devmapper"
5273

5374
# Checkout and compile iucode-tool for Intel CPU microcode
5475
# On non-x86_64 create a dummy file to copy below.
@@ -70,7 +91,7 @@ RUN set -e && \
7091
cp iucode_tool /iucode_tool; \
7192
fi
7293

73-
FROM alpine:3.11
94+
FROM alpine:3.13
7495

7596
COPY --from=mirror /etc/apk/repositories /etc/apk/repositories
7697
COPY --from=mirror /etc/apk/repositories.upstream /etc/apk/repositories.upstream

tools/alpine/README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# LinuxKit Alpine
2+
3+
`linuxkit/alpine` is the base image for almost all other packages built by linuxkit, including builders, tools and actual container images
4+
that are used in various parts of linuxkit yaml files.
5+
6+
This provides a reliable, consistent and repetable build.
7+
8+
This directory contains the source of `linuxkit/alpine`.
9+
10+
## Building
11+
12+
To build, run:
13+
14+
```
15+
make build
16+
```
17+
18+
## Pushing
19+
20+
To push, run:
21+
22+
```
23+
make push
24+
```
25+
26+
For a proper release process, see [docs/releasing.md](../../docs/releasing.md).
27+
28+
## Updating Sources and Packages
29+
30+
The base build for `linuxkit/alpine` is [library/alpine](https://hub.docker.io/_/alpine). The specific version is set in two `FROM` lines in
31+
the [Dockerfile](./Dockerfile) in this directory.
32+
33+
The packages installed come from several sources:
34+
35+
* [packages](./packages) - this file contains the list of packages to mirror locally in `linuxkit/alpine`, and will be available to all downstream users of `linuxkit/alpine`. These are installed using the default `apk` package version for the specific version of alpine. For example, if the line starts with `FROM alpine:3.13` and `packages` contains `file`, then it will run simply `apk add file`. The packages listed in [packages](./packages) are installed on all architectures.
36+
* `packages.<arch>` - these files contain the list of packages to mirror locally in `linuxkit/alpine`, like `packages`, but only for the specified architecture. For example, [packages.x86_64](./packages.x86_64) contains packages to be installed only on `linuxkit/alpine` for `x84_64`.
37+
* `packages.repo.<name>` - these files contain the list of packages to mirror locally in `linuxkit/alpine`, like `packages`, but to pull those packages from the provided `<name>` of Alpine's `apk` repo. For example, `packages.repo.edge` installs packages from Alpine's `edge` package repository.
38+
* `packages.<arch>.repo.<name>` - these files contain the list of packages to mirror locally in `linuxkit/alpine` for a specific architecture, like `packages.<arch>`, but to pull those packages from the provided `<name>` of Alpine's `apk` repor. For example, `packages.x86_64.repo.edge` installs packages from Alpine's `edge` package repository, hut only when building for `86_64`.
39+
40+
In addition, the [Dockerfile](./Dockerfile) may install certain packages directly from source, if they are not available in the `apk` repositories, or the versions are
41+
insufficient.
42+
43+
The final versions of packages installed are available in `versions.<arch>`.

tools/alpine/go-compile.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ dir="$1"
1313

1414
cd "$dir"
1515

16+
# Use '-mod=vendor' for builds which have switched to go modules
17+
[ -f go.mod -a -d vendor ] && export GOFLAGS="-mod=vendor"
18+
1619
# lint before building
1720
>&2 echo "gofmt..."
1821
test -z $(gofmt -s -l .| grep -v .pb. | grep -v vendor/ | tee /dev/stderr)
@@ -33,4 +36,5 @@ go test
3336

3437
[ "${REQUIRE_CGO}" = 1 ] || export CGO_ENABLED=0
3538

36-
go install -buildmode pie -ldflags "-s -w ${ldflags} -extldflags \"-fno-PIC -static\""
39+
go install -buildmode pie -ldflags "-linkmode=external -s -w ${ldflags} -extldflags \"-fno-PIC -static\""
40+

tools/alpine/packages

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ gettext-dev
4949
git
5050
gmp-dev
5151
gnupg
52-
go
5352
grep
5453
hvtools
5554
installkernel
@@ -68,6 +67,7 @@ libcap-ng-dev
6867
libedit-dev
6968
libressl-dev
7069
libseccomp-dev
70+
libseccomp-static
7171
libtirpc-dev
7272
libtool
7373
linux-headers

tools/alpine/packages.repo.edge

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go

0 commit comments

Comments
 (0)