Ignore previous release-artifacts so that repeated builds rebuild them. Before
this patch, building the dockerfile multiple times would rebuild the binaries,
but would not produce a new release-artifact (`.tar.gz`), because the make
target would not trigger if the file was already present.
With this patch, existing release-artifacts are no longer copied into the
Dockerfile, which prevents this, as well as saving some time copying files
that won't be used.
In addition to the above, other excludes were copied from the .gitignore,
to prevent cache-busts.
I also added `.DS_Store` files to the ignore-file. These files are generated
on macOS when navigating the filesystem, and would cause the build to fail if
present, as well as invalidating the build-cache;
docker buildx build --build-arg RELEASE_VER=main --build-arg UBUNTU_VERSION=22.04 --build-arg GO_VERSION=1.21.5 -f .github/workflows/release/Dockerfile -o releases/ .
...
> [target 4/4] RUN export GIT_STATUS_OUTPUT=$(git status --porcelain) && test -z $GIT_STATUS_OUTPUT || (echo $GIT_STATUS_OUTPUT && exit 1):
0.118 ++ git status --porcelain
1.405 + export 'GIT_STATUS_OUTPUT=?? .DS_Store
1.405 ?? .github/.DS_Store
...
1.407 + test -z gc .DS_Store gc .github/.DS_Store gc api/.DS_Store gc api/api/ gc api/runtime/.DS_Store gc api/services/.DS_Store gc api/types/.DS_Store gc archive/.DS_Store gc cmd/.DS_Store gc cmd/containerd-shim-runc-v2/.DS_Store gc cmd/containerd-shim-runc-v2/vendor/ gc cmd/containerd/.DS_Store gc cmd/ctr/.DS_Store gc content/.DS_Store gc contrib/.DS_Store gc contrib/ansible/.DS_Store gc contrib/seccomp/.DS_Store gc diff/.DS_Store gc docs/.DS_Store gc docs/historical/.DS_Store gc events/.DS_Store gc gc/.DS_Store gc images/.DS_Store gc images/converter/.DS_Store gc integration/.DS_Store gc integration/cri-api/.DS_Store gc integration/failpoint/.DS_Store gc integration/images/.DS_Store gc integration/remote/.DS_Store gc leases/.DS_Store gc metadata/.DS_Store gc metrics/.DS_Store gc metrics/cgroups/.DS_Store gc metrics/types/.DS_Store gc pkg/.DS_Store gc pkg/cri/.DS_Store gc pkg/oom/.DS_Store gc pkg/transfer/.DS_Store gc plugins/.DS_Store gc protobuf/.DS_Store gc releases/.DS_Store
1.407 /bin/bash: line 1: test: too many arguments
1.408 + echo gc .DS_Store gc .github/.DS_Store gc api/.DS_Store gc api/api/ gc api/runtime/.DS_Store gc api/services/.DS_Store gc api/types/.DS_Store gc archive/.DS_Store gc cmd/.DS_Store gc cmd/containerd-shim-runc-v2/.DS_Store gc cmd/containerd-shim-runc-v2/vendor/ gc cmd/containerd/.DS_Store gc cmd/ctr/.DS_Store gc content/.DS_Store gc contrib/.DS_Store gc contrib/ansible/.DS_Store gc contrib/seccomp/.DS_Store gc diff/.DS_Store gc docs/.DS_Store gc docs/historical/.DS_Store gc events/.DS_Store gc gc/.DS_Store gc images/.DS_Store gc images/converter/.DS_Store gc integration/.DS_Store gc integration/cri-api/.DS_Store gc integration/failpoint/.DS_Store gc integration/images/.DS_Store gc integration/remote/.DS_Store gc leases/.DS_Store gc metadata/.DS_Store gc metrics/.DS_Store gc metrics/cgroups/.DS_Store gc metrics/types/.DS_Store gc pkg/.DS_Store gc pkg/cri/.DS_Store gc pkg/oom/.DS_Store gc pkg/transfer/.DS_Store gc plugins/.DS_Store gc protobuf/.DS_Store gc releases/.DS_Store
1.408 + exit 1
1.408 gc .DS_Store gc .github/.DS_Store gc api/.DS_Store gc api/api/ gc api/runtime/.DS_Store gc api/services/.DS_Store gc api/types/.DS_Store gc archive/.DS_Store gc cmd/.DS_Store gc cmd/containerd-shim-runc-v2/.DS_Store gc cmd/containerd-shim-runc-v2/vendor/ gc cmd/containerd/.DS_Store gc cmd/ctr/.DS_Store gc content/.DS_Store gc contrib/.DS_Store gc contrib/ansible/.DS_Store gc contrib/seccomp/.DS_Store gc diff/.DS_Store gc docs/.DS_Store gc docs/historical/.DS_Store gc events/.DS_Store gc gc/.DS_Store gc images/.DS_Store gc images/converter/.DS_Store gc integration/.DS_Store gc integration/cri-api/.DS_Store gc integration/failpoint/.DS_Store gc integration/images/.DS_Store gc integration/remote/.DS_Store gc leases/.DS_Store gc metadata/.DS_Store gc metrics/.DS_Store gc metrics/cgroups/.DS_Store gc metrics/types/.DS_Store gc pkg/.DS_Store gc pkg/cri/.DS_Store gc pkg/oom/.DS_Store gc pkg/transfer/.DS_Store gc plugins/.DS_Store gc protobuf/.DS_Store gc releases/.DS_Store
Finally, I removed a redundant "echo", which causes (as seen above) the list
of uncommitted files to be printed twice (or three times even). We already print
the list of files, as well as print the `test -z` command that is executed, which
includes the list of files (`$GIT_STATUS_OUTPUT`). With this patch applied;
6.307 + test -z gc .DS_Store gc .github/.DS_Store gc api/.DS_Store gc api/api/ gc api/runtime/.DS_Store gc api/services/.DS_Store gc api/types/.DS_Store gc archive/.DS_Store gc cmd/.DS_Store gc cmd/containerd-shim-runc-v2/.DS_Store gc cmd/containerd-shim-runc-v2/vendor/ gc cmd/containerd/.DS_Store gc cmd/ctr/.DS_Store gc content/.DS_Store gc contrib/.DS_Store gc contrib/ansible/.DS_Store gc contrib/seccomp/.DS_Store gc diff/.DS_Store gc docs/.DS_Store gc docs/historical/.DS_Store gc events/.DS_Store gc gc/.DS_Store gc images/.DS_Store gc images/converter/.DS_Store gc integration/.DS_Store gc integration/cri-api/.DS_Store gc integration/failpoint/.DS_Store gc integration/images/.DS_Store gc integration/remote/.DS_Store gc leases/.DS_Store gc metadata/.DS_Store gc metrics/.DS_Store gc metrics/cgroups/.DS_Store gc metrics/types/.DS_Store gc pkg/.DS_Store gc pkg/cri/.DS_Store gc pkg/oom/.DS_Store gc pkg/transfer/.DS_Store gc plugins/.DS_Store gc protobuf/.DS_Store gc releases/.DS_Store
6.307 /bin/bash: line 1: test: too many arguments
6.308 + echo 'git repository contains uncommitted changes'
6.308 + exit 1
6.308 git repository contains uncommitted changes
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
63 lines
2.2 KiB
Docker
63 lines
2.2 KiB
Docker
# Copyright The containerd Authors.
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# UBUNTU_VERSION can be set to 18.04 (bionic, DEPRECATED), 20.04 (focal), or 22.04 (jammy)
|
|
ARG UBUNTU_VERSION=20.04
|
|
ARG BASE_IMAGE=ubuntu:${UBUNTU_VERSION}
|
|
ARG GO_VERSION
|
|
ARG GO_IMAGE=golang:${GO_VERSION}
|
|
FROM --platform=$BUILDPLATFORM $GO_IMAGE AS go
|
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.2.1@sha256:8879a398dedf0aadaacfbd332b29ff2f84bc39ae6d4e9c0a1109db27ac5ba012 AS xx
|
|
|
|
FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS base
|
|
COPY --from=xx / /
|
|
SHELL ["/bin/bash", "-xec"]
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
RUN apt-get update && \
|
|
apt-get install -y dpkg-dev git make pkg-config
|
|
ARG TARGETPLATFORM
|
|
# gcc is needed for github.com/containerd/btrfs/v2
|
|
RUN xx-apt-get install -y gcc
|
|
ENV PATH=/usr/local/go/bin:$PATH
|
|
ENV GOPATH=/go
|
|
ENV CGO_ENABLED=1
|
|
|
|
FROM base AS linux
|
|
FROM base AS windows
|
|
# Set variables used by cni script which would otherwise shell out to powershell
|
|
ARG GATEWAY
|
|
ARG PREFIX_LEN
|
|
|
|
FROM ${TARGETOS} AS target
|
|
WORKDIR /go/src/github.com/containerd/containerd
|
|
COPY . .
|
|
ARG TARGETPLATFORM
|
|
ARG RELEASE_VER
|
|
ENV VERSION=$RELEASE_VER
|
|
RUN \
|
|
--mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
--mount=type=cache,target=/go/pkg \
|
|
export CC=$(xx-info)-gcc && xx-go --wrap && \
|
|
make release static-release && \
|
|
for f in $(find bin -executable -type f); do xx-verify $f; done
|
|
|
|
# check git working tree after build
|
|
RUN \
|
|
export GIT_STATUS_OUTPUT=$(git status --porcelain) && \
|
|
test -z $GIT_STATUS_OUTPUT || (echo "repository contains uncommitted changes" && exit 1)
|
|
|
|
FROM scratch AS release
|
|
COPY --from=target /go/src/github.com/containerd/containerd/releases/ /
|