2020-12-07 16:40:18 +03:00
# syntax = docker/dockerfile-upstream:1.2.0-labs
2019-07-06 09:20:24 +03:00
2019-08-07 01:08:27 +03:00
# Meta args applied to stage base names.
2019-07-13 03:24:51 +03:00
ARG TOOLS
2020-05-08 21:44:20 +03:00
ARG IMPORTVET
2020-09-07 16:52:26 +03:00
ARG PKGS
2020-10-30 01:08:05 +03:00
ARG EXTRAS
2021-05-31 20:30:01 +03:00
ARG INSTALLER_ARCH
2020-09-07 16:52:26 +03:00
# Resolve package images using ${PKGS} to be used later in COPY --from=.
2022-03-23 20:02:22 +03:00
FROM ghcr.io/siderolabs/fhs:${PKGS} AS pkg-fhs
FROM ghcr.io/siderolabs/ca-certificates:${PKGS} AS pkg-ca-certificates
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/cryptsetup:${PKGS} AS pkg-cryptsetup-amd64
FROM --platform=arm64 ghcr.io/siderolabs/cryptsetup:${PKGS} AS pkg-cryptsetup-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/containerd:${PKGS} AS pkg-containerd-amd64
FROM --platform=arm64 ghcr.io/siderolabs/containerd:${PKGS} AS pkg-containerd-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/dosfstools:${PKGS} AS pkg-dosfstools-amd64
FROM --platform=arm64 ghcr.io/siderolabs/dosfstools:${PKGS} AS pkg-dosfstools-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/eudev:${PKGS} AS pkg-eudev-amd64
FROM --platform=arm64 ghcr.io/siderolabs/eudev:${PKGS} AS pkg-eudev-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM ghcr.io/siderolabs/grub:${PKGS} AS pkg-grub
FROM --platform=amd64 ghcr.io/siderolabs/grub:${PKGS} AS pkg-grub-amd64
FROM --platform=arm64 ghcr.io/siderolabs/grub:${PKGS} AS pkg-grub-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/iptables:${PKGS} AS pkg-iptables-amd64
FROM --platform=arm64 ghcr.io/siderolabs/iptables:${PKGS} AS pkg-iptables-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/libinih:${PKGS} AS pkg-libinih-amd64
FROM --platform=arm64 ghcr.io/siderolabs/libinih:${PKGS} AS pkg-libinih-arm64
2022-02-21 21:18:49 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/libjson-c:${PKGS} AS pkg-libjson-c-amd64
FROM --platform=arm64 ghcr.io/siderolabs/libjson-c:${PKGS} AS pkg-libjson-c-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/libpopt:${PKGS} AS pkg-libpopt-amd64
FROM --platform=arm64 ghcr.io/siderolabs/libpopt:${PKGS} AS pkg-libpopt-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/liburcu:${PKGS} AS pkg-liburcu-amd64
FROM --platform=arm64 ghcr.io/siderolabs/liburcu:${PKGS} AS pkg-liburcu-arm64
2022-02-21 21:18:49 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/openssl:${PKGS} AS pkg-openssl-amd64
FROM --platform=arm64 ghcr.io/siderolabs/openssl:${PKGS} AS pkg-openssl-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/libseccomp:${PKGS} AS pkg-libseccomp-amd64
FROM --platform=arm64 ghcr.io/siderolabs/libseccomp:${PKGS} AS pkg-libseccomp-arm64
2021-04-16 14:33:34 +03:00
2022-01-26 21:11:34 +03:00
# linux-firmware is not arch-specific
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/linux-firmware:${PKGS} AS pkg-linux-firmware
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/lvm2:${PKGS} AS pkg-lvm2-amd64
FROM --platform=arm64 ghcr.io/siderolabs/lvm2:${PKGS} AS pkg-lvm2-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/libaio:${PKGS} AS pkg-libaio-amd64
FROM --platform=arm64 ghcr.io/siderolabs/libaio:${PKGS} AS pkg-libaio-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/musl:${PKGS} AS pkg-musl-amd64
FROM --platform=arm64 ghcr.io/siderolabs/musl:${PKGS} AS pkg-musl-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/runc:${PKGS} AS pkg-runc-amd64
FROM --platform=arm64 ghcr.io/siderolabs/runc:${PKGS} AS pkg-runc-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/xfsprogs:${PKGS} AS pkg-xfsprogs-amd64
FROM --platform=arm64 ghcr.io/siderolabs/xfsprogs:${PKGS} AS pkg-xfsprogs-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/util-linux:${PKGS} AS pkg-util-linux-amd64
FROM --platform=arm64 ghcr.io/siderolabs/util-linux:${PKGS} AS pkg-util-linux-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=amd64 ghcr.io/siderolabs/kmod:${PKGS} AS pkg-kmod-amd64
FROM --platform=arm64 ghcr.io/siderolabs/kmod:${PKGS} AS pkg-kmod-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM ghcr.io/siderolabs/kernel:${PKGS} AS pkg-kernel
FROM --platform=amd64 ghcr.io/siderolabs/kernel:${PKGS} AS pkg-kernel-amd64
FROM --platform=arm64 ghcr.io/siderolabs/kernel:${PKGS} AS pkg-kernel-arm64
2021-04-16 14:33:34 +03:00
2022-03-23 20:02:22 +03:00
FROM --platform=arm64 ghcr.io/siderolabs/u-boot:${PKGS} AS pkg-u-boot-arm64
FROM --platform=arm64 ghcr.io/siderolabs/raspberrypi-firmware:${PKGS} AS pkg-raspberrypi-firmware-arm64
2019-08-07 01:08:27 +03:00
2020-10-30 01:08:05 +03:00
# Resolve package images using ${EXTRAS} to be used later in COPY --from=.
2022-03-23 20:02:22 +03:00
FROM ghcr.io/siderolabs/talosctl-cni-bundle-install:${EXTRAS} AS extras-talosctl-cni-bundle-install
2020-10-30 01:08:05 +03:00
2019-08-07 01:08:27 +03:00
# The tools target provides base toolchain for the build.
2020-05-08 21:44:20 +03:00
FROM $IMPORTVET as importvet
2021-04-16 14:33:34 +03:00
FROM --platform=${BUILDPLATFORM} $TOOLS AS tools
2019-09-10 21:12:28 +03:00
ENV PATH /toolchain/bin:/toolchain/go/bin
2019-07-13 03:24:51 +03:00
RUN [ "/toolchain/bin/mkdir" , "/bin" , "/tmp" ]
RUN [ "/toolchain/bin/ln" , "-svf" , "/toolchain/bin/bash" , "/bin/sh" ]
RUN [ "/toolchain/bin/ln" , "-svf" , "/toolchain/etc/ssl" , "/etc/ssl" ]
2021-11-12 18:41:19 +03:00
ARG GOLANGCILINT_VERSION
2022-01-26 16:02:31 +03:00
RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/${ GOLANGCILINT_VERSION } /install.sh | bash -s -- -b /toolchain/bin ${ GOLANGCILINT_VERSION }
2022-03-23 10:49:07 +03:00
ARG GOIMPORTS_VERSION
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache go install golang.org/x/tools/cmd/goimports@${ GOIMPORTS_VERSION } \
2022-03-23 10:49:07 +03:00
&& mv /go/bin/goimports /toolchain/go/bin/goimports
2020-07-16 16:25:04 +03:00
ARG GOFUMPT_VERSION
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache go install mvdan.cc/gofumpt@${ GOFUMPT_VERSION } \
2022-03-23 10:49:07 +03:00
&& mv /go/bin/gofumpt /toolchain/go/bin/gofumpt
2022-05-12 17:50:39 +03:00
ARG DEEPCOPY_VERSION
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache go install github.com/siderolabs/deep-copy@${ DEEPCOPY_VERSION } \
2022-05-12 17:50:39 +03:00
&& mv /go/bin/deep-copy /toolchain/go/bin/deep-copy
2021-04-12 15:34:48 +03:00
ARG STRINGER_VERSION
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache go install golang.org/x/tools/cmd/stringer@${ STRINGER_VERSION } \
2021-04-12 15:34:48 +03:00
&& mv /go/bin/stringer /toolchain/go/bin/stringer
2021-12-30 15:57:32 +03:00
ARG ENUMER_VERSION
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache go install github.com/alvaroloes/enumer@${ ENUMER_VERSION } \
2021-12-30 15:57:32 +03:00
&& mv /go/bin/enumer /toolchain/go/bin/enumer
2021-07-07 18:12:53 +03:00
ARG DEEPCOPY_GEN_VERSION
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache go install k8s.io/code-generator/cmd/deepcopy-gen@${ DEEPCOPY_GEN_VERSION } \
2021-07-07 18:12:53 +03:00
&& mv /go/bin/deepcopy-gen /toolchain/go/bin/deepcopy-gen
2021-08-09 14:46:00 +03:00
ARG VTPROTOBUF_VERSION
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@${ VTPROTOBUF_VERSION } \
2021-08-09 14:46:00 +03:00
&& mv /go/bin/protoc-gen-go-vtproto /toolchain/go/bin/protoc-gen-go-vtproto
2021-01-10 11:25:39 +03:00
RUN curl -sfL https://github.com/uber/prototool/releases/download/v1.10.0/prototool-Linux-x86_64.tar.gz | tar -xz --strip-components= 2 -C /toolchain/bin prototool/bin/prototool
2021-06-07 20:07:06 +03:00
COPY ./hack/docgen /go/src/github.com/talos-systems/talos-hack-docgen
2022-05-31 21:42:11 +03:00
RUN --mount= type = cache,target= /.cache cd /go/src/github.com/talos-systems/talos-hack-docgen \
2021-06-07 20:07:06 +03:00
&& go build -o docgen . \
2019-11-09 18:22:43 +03:00
&& mv docgen /toolchain/go/bin/
2020-05-08 21:44:20 +03:00
COPY --from= importvet /importvet /toolchain/go/bin/importvet
2019-07-13 03:24:51 +03:00
# The build target creates a container that will be used to build Talos source
# code.
2021-04-16 14:33:34 +03:00
FROM --platform=${BUILDPLATFORM} tools AS build
2019-07-13 03:24:51 +03:00
SHELL [ "/toolchain/bin/bash" , "-c" ]
ENV PATH /toolchain/bin:/toolchain/go/bin
ENV GO111MODULE on
ENV GOPROXY https://proxy.golang.org
2021-03-29 17:27:23 +03:00
ARG CGO_ENABLED
ENV CGO_ENABLED ${ CGO_ENABLED }
2021-03-25 00:20:44 +03:00
ENV GOCACHE /.cache/go-build
ENV GOMODCACHE /.cache/mod
2021-11-23 18:03:38 +03:00
ENV PROTOTOOL_CACHE_PATH /.cache/prototool
2021-08-10 22:49:33 +03:00
ARG SOURCE_DATE_EPOCH
ENV SOURCE_DATE_EPOCH ${ SOURCE_DATE_EPOCH }
2019-07-13 03:24:51 +03:00
WORKDIR /src
2018-12-20 09:22:05 +03:00
2021-04-05 20:55:53 +03:00
# The build-go target creates a container to build Go code with Go modules downloaded and verified.
FROM build AS build-go
COPY ./go.mod ./go.sum ./
COPY ./pkg/machinery/go.mod ./pkg/machinery/go.sum ./pkg/machinery/
WORKDIR /src/pkg/machinery
RUN --mount= type = cache,target= /.cache go mod download
WORKDIR /src
RUN --mount= type = cache,target= /.cache go mod download
RUN --mount= type = cache,target= /.cache go mod verify
2021-04-01 19:46:54 +03:00
# The generate target generates code from protobuf service definitions and machinery config.
2019-01-18 17:26:12 +03:00
2021-11-29 20:45:31 +03:00
# generate API descriptors
FROM build AS api-descriptors-build
WORKDIR /src/api
COPY api .
RUN --mount= type = cache,target= /.cache prototool format --overwrite --protoc-bin-path= /toolchain/bin/protoc --protoc-wkt-path= /toolchain/include
RUN --mount= type = cache,target= /.cache prototool break descriptor-set --output-path= api.descriptors --protoc-bin-path= /toolchain/bin/protoc --protoc-wkt-path= /toolchain/include
FROM --platform=${BUILDPLATFORM} scratch AS api-descriptors
COPY --from= api-descriptors-build /src/api/api.descriptors /api/api.descriptors
2021-11-23 18:03:38 +03:00
# format protobuf service definitions
FROM build AS proto-format-build
WORKDIR /src/api
COPY api .
RUN --mount= type = cache,target= /.cache prototool format --overwrite --protoc-bin-path= /toolchain/bin/protoc --protoc-wkt-path= /toolchain/include
FROM --platform=${BUILDPLATFORM} scratch AS fmt-protobuf
COPY --from= proto-format-build /src/api/ /api/
# compile protobuf service definitions
2019-07-13 03:24:51 +03:00
FROM build AS generate-build
2021-11-23 18:03:38 +03:00
COPY --from= proto-format-build /src/api /api/
2019-10-24 05:31:18 +03:00
# Common needs to be at or near the top to satisfy the subsequent imports
2020-12-23 18:08:12 +03:00
COPY ./api/vendor/ /api/vendor/
2019-10-21 21:21:46 +03:00
COPY ./api/common/common.proto /api/common/common.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size common/common.proto
2019-10-21 21:21:46 +03:00
COPY ./api/security/security.proto /api/security/security.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size security/security.proto
2020-11-11 20:17:46 +03:00
COPY ./api/storage/storage.proto /api/storage/storage.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size storage/storage.proto
2019-10-21 21:21:46 +03:00
COPY ./api/machine/machine.proto /api/machine/machine.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size machine/machine.proto
2019-10-21 21:21:46 +03:00
COPY ./api/time/time.proto /api/time/time.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size time/time.proto
2020-07-13 23:48:41 +03:00
COPY ./api/cluster/cluster.proto /api/cluster/cluster.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size cluster/cluster.proto
2021-01-12 15:52:24 +03:00
COPY ./api/resource/resource.proto /api/resource/resource.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size resource/resource.proto
2021-06-22 19:23:41 +03:00
COPY ./api/resource/secrets/secrets.proto /api/resource/secrets/secrets.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size resource/secrets/secrets.proto
2021-01-19 15:45:50 +03:00
COPY ./api/inspect/inspect.proto /api/inspect/inspect.proto
2021-08-09 14:46:00 +03:00
RUN protoc -I/api -I/api/vendor/ --go_out= paths = source_relative:/api --go-grpc_out= paths = source_relative:/api --go-vtproto_out= paths = source_relative:/api --go-vtproto_opt= features = marshal+unmarshal+size inspect/inspect.proto
2022-03-23 10:49:07 +03:00
# Goimports and gofumpt generated files to adjust import order
RUN goimports -w -local github.com/talos-systems/talos /api/
RUN gofumpt -w /api/
2019-07-21 21:27:15 +03:00
2020-10-20 22:05:13 +03:00
# run docgen for machinery config
2021-04-05 20:55:53 +03:00
FROM build-go AS go-generate
2021-05-26 19:37:29 +03:00
COPY ./pkg ./pkg
2021-07-07 18:12:53 +03:00
COPY ./hack/boilerplate.txt ./hack/boilerplate.txt
2021-05-26 19:37:29 +03:00
RUN --mount= type = cache,target= /.cache go generate ./pkg/...
2022-03-23 10:49:07 +03:00
RUN goimports -w -local github.com/talos-systems/talos ./pkg/
RUN gofumpt -w ./pkg/
2021-05-26 19:37:29 +03:00
WORKDIR /src/pkg/machinery
RUN --mount= type = cache,target= /.cache go generate ./...
2022-03-23 10:49:07 +03:00
RUN goimports -w -local github.com/talos-systems/talos ./
RUN gofumpt -w ./
2020-10-20 22:05:13 +03:00
2022-04-01 20:39:03 +03:00
FROM build AS embed-generate
ARG NAME
ARG SHA
ARG USERNAME
ARG REGISTRY
ARG TAG
ARG ARTIFACTS
ARG PKGS
ARG EXTRAS
RUN mkdir -p pkg/machinery/gendata/data && \
echo -n ${ NAME } > pkg/machinery/gendata/data/name && \
echo -n ${ SHA } > pkg/machinery/gendata/data/sha && \
echo -n ${ USERNAME } > pkg/machinery/gendata/data/username && \
echo -n ${ REGISTRY } > pkg/machinery/gendata/data/registry && \
echo -n ${ EXTRAS } > pkg/machinery/gendata/data/extras && \
echo -n ${ PKGS } > pkg/machinery/gendata/data/pkgs && \
echo -n ${ TAG } > pkg/machinery/gendata/data/tag && \
echo -n ${ ARTIFACTS } > pkg/machinery/gendata/data/artifacts
FROM scratch AS embed
COPY --from= embed-generate /src/pkg/machinery/gendata/data /pkg/machinery/gendata/data
FROM embed-generate AS embed-abbrev-generate
2022-03-28 12:07:37 +03:00
ARG ABBREV_TAG
RUN echo -n "undefined" > pkg/machinery/gendata/data/sha && \
echo -n ${ ABBREV_TAG } > pkg/machinery/gendata/data/tag
2022-04-01 20:39:03 +03:00
FROM scratch AS embed-abbrev
COPY --from= embed-abbrev-generate /src/pkg/machinery/gendata/data /pkg/machinery/gendata/data
2021-04-16 14:33:34 +03:00
FROM --platform=${BUILDPLATFORM} scratch AS generate
2021-11-23 18:03:38 +03:00
COPY --from= proto-format-build /src/api /api/
2021-01-10 11:25:39 +03:00
COPY --from= generate-build /api/common/*.pb.go /pkg/machinery/api/common/
COPY --from= generate-build /api/security/*.pb.go /pkg/machinery/api/security/
COPY --from= generate-build /api/machine/*.pb.go /pkg/machinery/api/machine/
COPY --from= generate-build /api/time/*.pb.go /pkg/machinery/api/time/
COPY --from= generate-build /api/cluster/*.pb.go /pkg/machinery/api/cluster/
COPY --from= generate-build /api/storage/*.pb.go /pkg/machinery/api/storage/
2021-01-12 15:52:24 +03:00
COPY --from= generate-build /api/resource/*.pb.go /pkg/machinery/api/resource/
2021-06-22 19:23:41 +03:00
COPY --from= generate-build /api/resource/secrets/*.pb.go /pkg/machinery/api/resource/secrets/
2021-01-19 15:45:50 +03:00
COPY --from= generate-build /api/inspect/*.pb.go /pkg/machinery/api/inspect/
2021-11-15 19:49:56 +03:00
COPY --from= go-generate /src/pkg/machinery/resources/kubespan/ /pkg/machinery/resources/kubespan/
COPY --from= go-generate /src/pkg/machinery/resources/network/ /pkg/machinery/resources/network/
2021-05-05 22:50:54 +03:00
COPY --from= go-generate /src/pkg/machinery/config/types/v1alpha1/ /pkg/machinery/config/types/v1alpha1/
2021-05-24 16:34:38 +03:00
COPY --from= go-generate /src/pkg/machinery/nethelpers/ /pkg/machinery/nethelpers/
2022-02-10 23:30:09 +03:00
COPY --from= go-generate /src/pkg/machinery/extensions/ /pkg/machinery/extensions/
2022-04-01 20:39:03 +03:00
COPY --from= embed-abbrev / /
2019-03-28 02:33:03 +03:00
2019-07-13 03:24:51 +03:00
# The base target provides a container that can be used to build all Talos
# assets.
2019-01-18 17:26:12 +03:00
2021-04-05 20:55:53 +03:00
FROM build-go AS base
2019-04-11 02:50:56 +03:00
COPY ./cmd ./cmd
COPY ./pkg ./pkg
COPY ./internal ./internal
2021-05-24 16:34:38 +03:00
COPY --from= generate /pkg/machinery/ ./pkg/machinery/
2022-04-01 20:39:03 +03:00
COPY --from= embed / ./
2021-08-18 20:16:54 +03:00
RUN --mount= type = cache,target= /.cache go list all >/dev/null
2020-11-09 23:10:19 +03:00
WORKDIR /src/pkg/machinery
2021-03-25 00:20:44 +03:00
RUN --mount= type = cache,target= /.cache go mod download
2021-08-18 20:16:54 +03:00
RUN --mount= type = cache,target= /.cache go list all >/dev/null
2020-11-09 23:10:19 +03:00
WORKDIR /src
2018-12-20 09:22:05 +03:00
2019-07-13 03:24:51 +03:00
# The init target builds the init binary.
2021-04-16 14:33:34 +03:00
FROM base AS init-build-amd64
WORKDIR /src/internal/app/init
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /init
2021-04-16 14:33:34 +03:00
RUN chmod +x /init
FROM base AS init-build-arm64
2019-07-13 03:24:51 +03:00
WORKDIR /src/internal/app/init
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2021-04-16 14:33:34 +03:00
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = arm64 go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /init
2019-07-13 03:24:51 +03:00
RUN chmod +x /init
2019-07-21 21:27:15 +03:00
2021-04-16 14:33:34 +03:00
FROM init-build-${TARGETARCH} AS init-build
2019-07-13 03:24:51 +03:00
FROM scratch AS init
COPY --from= init-build /init /init
2021-03-22 23:47:35 +03:00
# The machined target builds the machined binary.
2019-07-16 18:09:35 +03:00
2021-04-16 14:33:34 +03:00
FROM base AS machined-build-amd64
WORKDIR /src/internal/app/machined
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /machined
2021-04-16 14:33:34 +03:00
RUN chmod +x /machined
FROM base AS machined-build-arm64
2019-07-16 18:09:35 +03:00
WORKDIR /src/internal/app/machined
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2021-04-16 14:33:34 +03:00
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = arm64 go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /machined
2019-07-16 18:09:35 +03:00
RUN chmod +x /machined
2019-07-21 21:27:15 +03:00
2021-04-16 14:33:34 +03:00
FROM machined-build-${TARGETARCH} AS machined-build
2019-07-16 18:09:35 +03:00
FROM scratch AS machined
COPY --from= machined-build /machined /machined
2020-03-21 03:38:48 +03:00
# The talosctl targets build the talosctl binaries.
2019-01-18 17:26:12 +03:00
2020-03-22 00:27:03 +03:00
FROM base AS talosctl-linux-amd64-build
2020-03-21 03:38:48 +03:00
WORKDIR /src/cmd/talosctl
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /talosctl-linux-amd64
2020-03-21 03:38:48 +03:00
RUN chmod +x /talosctl-linux-amd64
2019-07-21 21:27:15 +03:00
2020-03-22 00:27:03 +03:00
FROM base AS talosctl-linux-arm64-build
WORKDIR /src/cmd/talosctl
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = arm64 go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /talosctl-linux-arm64
2020-03-22 00:27:03 +03:00
RUN chmod +x /talosctl-linux-arm64
2020-03-22 04:08:09 +03:00
FROM base AS talosctl-linux-armv7-build
WORKDIR /src/cmd/talosctl
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = arm GOARM = 7 go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /talosctl-linux-armv7
2020-03-22 04:08:09 +03:00
RUN chmod +x /talosctl-linux-armv7
2020-03-21 03:38:48 +03:00
FROM scratch AS talosctl-linux
2020-03-22 00:27:03 +03:00
COPY --from= talosctl-linux-amd64-build /talosctl-linux-amd64 /talosctl-linux-amd64
COPY --from= talosctl-linux-arm64-build /talosctl-linux-arm64 /talosctl-linux-arm64
2020-03-22 04:08:09 +03:00
COPY --from= talosctl-linux-armv7-build /talosctl-linux-armv7 /talosctl-linux-armv7
2019-04-19 05:31:43 +03:00
2021-03-18 19:46:32 +03:00
FROM scratch as talosctl
ARG TARGETARCH
COPY --from= talosctl-linux /talosctl-linux-${ TARGETARCH } /talosctl
ARG TAG
ENV VERSION ${ TAG }
LABEL "alpha.talos.dev/version" = " ${ VERSION } "
2022-03-23 20:02:22 +03:00
LABEL org.opencontainers.image.source https://github.com/siderolabs/talos
2021-03-18 19:46:32 +03:00
ENTRYPOINT [ "/talosctl" ]
2021-04-20 15:58:30 +03:00
FROM base AS talosctl-darwin-amd64-build
2020-03-21 03:38:48 +03:00
WORKDIR /src/cmd/talosctl
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = darwin GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /talosctl-darwin-amd64
2020-03-21 03:38:48 +03:00
RUN chmod +x /talosctl-darwin-amd64
2019-07-21 21:27:15 +03:00
2021-04-20 15:58:30 +03:00
FROM base AS talosctl-darwin-arm64-build
WORKDIR /src/cmd/talosctl
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
RUN --mount= type = cache,target= /.cache GOOS = darwin GOARCH = arm64 go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /talosctl-darwin-arm64
RUN chmod +x /talosctl-darwin-arm64
2020-03-21 03:38:48 +03:00
FROM scratch AS talosctl-darwin
2021-04-20 15:58:30 +03:00
COPY --from= talosctl-darwin-amd64-build /talosctl-darwin-amd64 /talosctl-darwin-amd64
COPY --from= talosctl-darwin-arm64-build /talosctl-darwin-arm64 /talosctl-darwin-arm64
2019-04-19 05:31:43 +03:00
2021-08-25 19:08:48 +03:00
FROM base AS talosctl-windows-amd64-build
WORKDIR /src/cmd/talosctl
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = windows GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /talosctl-windows-amd64.exe
2021-08-25 19:08:48 +03:00
FROM scratch AS talosctl-windows
COPY --from= talosctl-windows-amd64-build /talosctl-windows-amd64.exe /talosctl-windows-amd64.exe
2019-04-19 05:31:43 +03:00
# The kernel target is the linux kernel.
2019-07-13 03:24:51 +03:00
FROM scratch AS kernel
2020-09-26 00:00:43 +03:00
ARG TARGETARCH
COPY --from= pkg-kernel /boot/vmlinuz /vmlinuz-${ TARGETARCH }
2019-04-19 05:31:43 +03:00
2019-07-21 21:27:15 +03:00
# The rootfs target provides the Talos rootfs.
2019-04-19 05:31:43 +03:00
2021-04-16 14:33:34 +03:00
FROM build AS rootfs-base-amd64
COPY --from= pkg-fhs / /rootfs
COPY --from= pkg-ca-certificates / /rootfs
COPY --from= pkg-cryptsetup-amd64 / /rootfs
COPY --from= pkg-containerd-amd64 / /rootfs
COPY --from= pkg-dosfstools-amd64 / /rootfs
COPY --from= pkg-eudev-amd64 / /rootfs
COPY --from= pkg-iptables-amd64 / /rootfs
2022-02-21 21:18:49 +03:00
COPY --from= pkg-libinih-amd64 / /rootfs
2021-04-16 14:33:34 +03:00
COPY --from= pkg-libjson-c-amd64 / /rootfs
COPY --from= pkg-libpopt-amd64 / /rootfs
2022-02-21 21:18:49 +03:00
COPY --from= pkg-liburcu-amd64 / /rootfs
COPY --from= pkg-openssl-amd64 / /rootfs
2021-04-16 14:33:34 +03:00
COPY --from= pkg-libseccomp-amd64 / /rootfs
COPY --from= pkg-lvm2-amd64 / /rootfs
COPY --from= pkg-libaio-amd64 / /rootfs
COPY --from= pkg-musl-amd64 / /rootfs
COPY --from= pkg-runc-amd64 / /rootfs
COPY --from= pkg-xfsprogs-amd64 / /rootfs
COPY --from= pkg-util-linux-amd64 /lib/libblkid.* /rootfs/lib/
COPY --from= pkg-util-linux-amd64 /lib/libuuid.* /rootfs/lib/
COPY --from= pkg-util-linux-amd64 /lib/libmount.* /rootfs/lib/
COPY --from= pkg-kmod-amd64 /usr/lib/libkmod.* /rootfs/lib/
COPY --from= pkg-kernel-amd64 /lib/modules /rootfs/lib/modules
COPY --from= machined-build-amd64 /machined /rootfs/sbin/init
2022-06-13 19:10:53 +03:00
# the orderly_poweroff call by the kernel will call '/sbin/poweroff'
RUN ln /rootfs/sbin/init /rootfs/sbin/poweroff
RUN chmod +x /rootfs/sbin/poweroff
2021-04-16 14:33:34 +03:00
# NB: We run the cleanup step before creating extra directories, files, and
# symlinks to avoid accidentally cleaning them up.
COPY ./hack/cleanup.sh /toolchain/bin/cleanup.sh
RUN cleanup.sh /rootfs
2022-01-26 07:37:49 +03:00
RUN mkdir -pv /rootfs/{ boot,etc/cri/conf.d/hosts,lib/firmware,usr/local/share,usr/share/zoneinfo/Etc,mnt,system,opt}
COPY --chmod= 0644 hack/zoneinfo/Etc/UTC /rootfs/usr/share/zoneinfo/Etc/UTC
RUN ln -s /usr/share/zoneinfo/Etc/UTC /rootfs/etc/localtime
2021-11-17 00:14:28 +03:00
RUN mkdir -pv /rootfs/{ etc/kubernetes/manifests,etc/cni/net.d,usr/libexec/kubernetes}
RUN mkdir -pv /rootfs/opt/{ containerd/bin,containerd/lib}
2022-01-18 22:19:36 +03:00
COPY --chmod= 0644 hack/containerd.toml /rootfs/etc/containerd/config.toml
COPY --chmod= 0644 hack/cri-containerd.toml /rootfs/etc/cri/containerd.toml
COPY --chmod= 0644 hack/cri-plugin.part /rootfs/etc/cri/conf.d/00-base.part
2022-01-20 20:53:28 +03:00
RUN touch /rootfs/etc/{ extensions.yaml,resolv.conf,hosts,os-release,machine-id,cri/conf.d/cri.toml,cri/conf.d/01-registries.part}
2022-06-29 15:51:56 +03:00
RUN ln -s ca-certificates /rootfs/etc/ssl/certs/ca-certificates.crt
2021-04-16 14:33:34 +03:00
RUN ln -s /etc/ssl /rootfs/etc/pki
RUN ln -s /etc/ssl /rootfs/usr/share/ca-certificates
RUN ln -s /etc/ssl /rootfs/usr/local/share/ca-certificates
RUN ln -s /etc/ssl /rootfs/etc/ca-certificates
FROM build AS rootfs-base-arm64
2020-09-07 16:52:26 +03:00
COPY --from= pkg-fhs / /rootfs
COPY --from= pkg-ca-certificates / /rootfs
2021-04-16 14:33:34 +03:00
COPY --from= pkg-cryptsetup-arm64 / /rootfs
COPY --from= pkg-containerd-arm64 / /rootfs
COPY --from= pkg-dosfstools-arm64 / /rootfs
COPY --from= pkg-eudev-arm64 / /rootfs
COPY --from= pkg-iptables-arm64 / /rootfs
2022-02-21 21:18:49 +03:00
COPY --from= pkg-libinih-arm64 / /rootfs
2021-04-16 14:33:34 +03:00
COPY --from= pkg-libjson-c-arm64 / /rootfs
COPY --from= pkg-libpopt-arm64 / /rootfs
2022-02-21 21:18:49 +03:00
COPY --from= pkg-liburcu-arm64 / /rootfs
COPY --from= pkg-openssl-arm64 / /rootfs
2021-04-16 14:33:34 +03:00
COPY --from= pkg-libseccomp-arm64 / /rootfs
COPY --from= pkg-lvm2-arm64 / /rootfs
COPY --from= pkg-libaio-arm64 / /rootfs
COPY --from= pkg-musl-arm64 / /rootfs
COPY --from= pkg-runc-arm64 / /rootfs
COPY --from= pkg-xfsprogs-arm64 / /rootfs
COPY --from= pkg-util-linux-arm64 /lib/libblkid.* /rootfs/lib/
COPY --from= pkg-util-linux-arm64 /lib/libuuid.* /rootfs/lib/
COPY --from= pkg-util-linux-arm64 /lib/libmount.* /rootfs/lib/
COPY --from= pkg-kmod-arm64 /usr/lib/libkmod.* /rootfs/lib/
COPY --from= pkg-kernel-arm64 /lib/modules /rootfs/lib/modules
COPY --from= machined-build-arm64 /machined /rootfs/sbin/init
2022-06-13 19:10:53 +03:00
# the orderly_poweroff call by the kernel will call '/sbin/poweroff'
RUN ln /rootfs/sbin/init /rootfs/sbin/poweroff
RUN chmod +x /rootfs/sbin/poweroff
2019-07-26 00:38:20 +03:00
# NB: We run the cleanup step before creating extra directories, files, and
# symlinks to avoid accidentally cleaning them up.
COPY ./hack/cleanup.sh /toolchain/bin/cleanup.sh
RUN cleanup.sh /rootfs
2022-01-26 07:37:49 +03:00
RUN mkdir -pv /rootfs/{ boot,etc/cri/conf.d/hosts,lib/firmware,usr/local/share,usr/share/zoneinfo/Etc,mnt,system,opt}
COPY --chmod= 0644 hack/zoneinfo/Etc/UTC /rootfs/usr/share/zoneinfo/Etc/UTC
RUN ln -s /usr/share/zoneinfo/Etc/UTC /rootfs/etc/localtime
2021-11-17 00:14:28 +03:00
RUN mkdir -pv /rootfs/{ etc/kubernetes/manifests,etc/cni/net.d,usr/libexec/kubernetes}
RUN mkdir -pv /rootfs/opt/{ containerd/bin,containerd/lib}
2022-01-18 22:19:36 +03:00
COPY --chmod= 0644 hack/containerd.toml /rootfs/etc/containerd/config.toml
COPY --chmod= 0644 hack/cri-containerd.toml /rootfs/etc/cri/containerd.toml
COPY --chmod= 0644 hack/cri-plugin.part /rootfs/etc/cri/conf.d/00-base.part
2022-01-20 20:53:28 +03:00
RUN touch /rootfs/etc/{ extensions.yaml,resolv.conf,hosts,os-release,machine-id,cri/conf.d/cri.toml,cri/conf.d/01-registries.part}
2019-07-21 21:27:15 +03:00
RUN ln -s /etc/ssl /rootfs/etc/pki
2022-06-29 15:51:56 +03:00
RUN ln -s ca-certificates /rootfs/etc/ssl/certs/ca-certificates.crt
2019-07-21 21:27:15 +03:00
RUN ln -s /etc/ssl /rootfs/usr/share/ca-certificates
RUN ln -s /etc/ssl /rootfs/usr/local/share/ca-certificates
RUN ln -s /etc/ssl /rootfs/etc/ca-certificates
2019-07-13 03:24:51 +03:00
2021-04-16 14:33:34 +03:00
FROM rootfs-base-${TARGETARCH} AS rootfs-base
FROM rootfs-base-arm64 AS rootfs-squashfs-arm64
2021-04-29 10:54:20 +03:00
RUN find /rootfs -print0 \
| xargs -0r touch --no-dereference --date= " @ ${ SOURCE_DATE_EPOCH } "
2021-04-16 14:33:34 +03:00
RUN mksquashfs /rootfs /rootfs.sqsh -all-root -noappend -comp xz -Xdict-size 100% -no-progress
FROM rootfs-base-amd64 AS rootfs-squashfs-amd64
2021-04-29 10:54:20 +03:00
RUN find /rootfs -print0 \
| xargs -0r touch --no-dereference --date= " @ ${ SOURCE_DATE_EPOCH } "
2019-07-27 11:09:50 +03:00
RUN mksquashfs /rootfs /rootfs.sqsh -all-root -noappend -comp xz -Xdict-size 100% -no-progress
2019-04-19 05:31:43 +03:00
2021-04-16 14:33:34 +03:00
FROM scratch AS squashfs-arm64
COPY --from= rootfs-squashfs-arm64 /rootfs.sqsh /
FROM scratch AS squashfs-amd64
COPY --from= rootfs-squashfs-amd64 /rootfs.sqsh /
2019-10-31 01:52:36 +03:00
2019-04-19 05:31:43 +03:00
FROM scratch AS rootfs
2019-07-21 21:27:15 +03:00
COPY --from= rootfs-base /rootfs /
# The initramfs target provides the Talos initramfs image.
2021-04-16 14:33:34 +03:00
FROM build AS initramfs-archive-arm64
WORKDIR /initramfs
COPY --from= squashfs-arm64 /rootfs.sqsh .
COPY --from= init-build-arm64 /init .
2022-01-13 22:38:07 +03:00
# copying over firmware binary blobs to initramfs
2022-01-26 21:11:34 +03:00
COPY --from= pkg-linux-firmware /lib/firmware/rtl_nic ./lib/firmware/rtl_nic
COPY --from= pkg-linux-firmware /lib/firmware/nvidia/tegra210 ./lib/firmware/nvidia/tegra210
2021-04-29 10:54:20 +03:00
RUN find . -print0 \
| xargs -0r touch --no-dereference --date= " @ ${ SOURCE_DATE_EPOCH } "
RUN set -o pipefail \
&& find . 2>/dev/null \
| LC_ALL = c sort \
| cpio --reproducible -H newc -o \
| xz -v -C crc32 -0 -e -T 0 -z \
> /initramfs.xz
2021-04-16 14:33:34 +03:00
FROM build AS initramfs-archive-amd64
2019-07-21 21:27:15 +03:00
WORKDIR /initramfs
2021-04-16 14:33:34 +03:00
COPY --from= squashfs-amd64 /rootfs.sqsh .
COPY --from= init-build-amd64 /init .
2022-01-26 21:11:34 +03:00
# copying over firmware binary blobs to initramfs
COPY --from= pkg-linux-firmware /lib/firmware/bnx2 ./lib/firmware/bnx2
COPY --from= pkg-linux-firmware /lib/firmware/bnx2x ./lib/firmware/bnx2x
2021-04-29 10:54:20 +03:00
RUN find . -print0 \
| xargs -0r touch --no-dereference --date= " @ ${ SOURCE_DATE_EPOCH } "
RUN set -o pipefail \
&& find . 2>/dev/null \
| LC_ALL = c sort \
| cpio --reproducible -H newc -o \
| xz -v -C crc32 -0 -e -T 0 -z \
> /initramfs.xz
2019-07-21 21:27:15 +03:00
2021-04-16 14:33:34 +03:00
FROM initramfs-archive-${TARGETARCH} AS initramfs-archive
2019-07-21 21:27:15 +03:00
FROM scratch AS initramfs
2020-09-26 00:00:43 +03:00
ARG TARGETARCH
COPY --from= initramfs-archive /initramfs.xz /initramfs-${ TARGETARCH } .xz
2019-04-19 05:31:43 +03:00
2019-12-24 23:23:52 +03:00
# The talos target generates a docker image that can be used to run Talos
2019-04-19 05:31:43 +03:00
# in containers.
2019-12-24 23:23:52 +03:00
FROM scratch AS talos
2019-07-21 21:27:15 +03:00
COPY --from= rootfs / /
2022-03-23 20:02:22 +03:00
LABEL org.opencontainers.image.source https://github.com/siderolabs/talos
2019-07-21 21:27:15 +03:00
ENTRYPOINT [ "/sbin/init" ]
2019-04-19 05:31:43 +03:00
2019-05-16 02:14:30 +03:00
# The installer target generates an image that can be used to install Talos to
# various environments.
2019-04-19 05:31:43 +03:00
2019-11-01 07:55:58 +03:00
FROM base AS installer-build
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2019-11-01 07:55:58 +03:00
WORKDIR /src/cmd/installer
2021-04-16 14:33:34 +03:00
ARG TARGETARCH
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = ${ TARGETARCH } go build ${ GO_BUILDFLAGS } -ldflags " ${ GO_LDFLAGS } " -o /installer
2019-11-01 07:55:58 +03:00
RUN chmod +x /installer
2022-05-31 20:19:36 +03:00
FROM alpine:3.16.0 AS unicode-pf2
2021-10-14 15:20:45 +03:00
RUN apk add --no-cache --update --no-scripts grub
2020-11-01 00:03:56 +03:00
2021-05-31 20:30:01 +03:00
FROM scratch AS install-artifacts-amd64
2021-04-16 14:33:34 +03:00
COPY --from= pkg-grub-amd64 /usr/lib/grub /usr/lib/grub
COPY --from= pkg-kernel-amd64 /boot/vmlinuz /usr/install/amd64/vmlinuz
COPY --from= pkg-kernel-amd64 /dtb /usr/install/amd64/dtb
COPY --from= initramfs-archive-amd64 /initramfs.xz /usr/install/amd64/initramfs.xz
2021-05-31 20:30:01 +03:00
FROM scratch AS install-artifacts-arm64
COPY --from= pkg-grub-arm64 /usr/lib/grub /usr/lib/grub
COPY --from= pkg-kernel-arm64 /boot/vmlinuz /usr/install/arm64/vmlinuz
COPY --from= pkg-kernel-arm64 /dtb /usr/install/arm64/dtb
2021-04-16 14:33:34 +03:00
COPY --from= initramfs-archive-arm64 /initramfs.xz /usr/install/arm64/initramfs.xz
COPY --from= pkg-u-boot-arm64 / /usr/install/arm64/u-boot
COPY --from= pkg-raspberrypi-firmware-arm64 / /usr/install/arm64/raspberrypi-firmware
2021-05-31 20:30:01 +03:00
FROM scratch AS install-artifacts-all
COPY --from= install-artifacts-amd64 / /
COPY --from= install-artifacts-arm64 / /
FROM install-artifacts-${TARGETARCH} AS install-artifacts-targetarch
FROM install-artifacts-${INSTALLER_ARCH} AS install-artifacts
COPY --from= pkg-grub / /
COPY --from= unicode-pf2 /usr/share/grub/unicode.pf2 /usr/share/grub/unicode.pf2
2022-05-31 20:19:36 +03:00
FROM alpine:3.16.0 AS installer
2021-10-05 22:32:46 +03:00
RUN apk add --no-cache --update --no-scripts \
2019-06-26 05:25:57 +03:00
bash \
2022-01-20 20:53:28 +03:00
cpio \
2020-08-19 01:52:26 +03:00
efibootmgr \
2020-11-01 00:03:56 +03:00
mtools \
2019-06-26 05:25:57 +03:00
qemu-img \
2022-01-20 20:53:28 +03:00
squashfs-tools \
2019-06-26 05:25:57 +03:00
util-linux \
2020-11-01 00:03:56 +03:00
xfsprogs \
xorriso \
xz
2020-09-26 00:00:43 +03:00
ARG TARGETARCH
2021-06-20 18:51:20 +03:00
ENV TARGETARCH ${ TARGETARCH }
2021-04-16 14:33:34 +03:00
COPY --from= install-artifacts / /
2019-11-01 07:55:58 +03:00
COPY --from= installer-build /installer /bin/installer
2020-03-21 03:38:48 +03:00
RUN ln -s /bin/installer /bin/talosctl
2019-04-19 05:31:43 +03:00
ARG TAG
ENV VERSION ${ TAG }
2019-12-30 06:43:40 +03:00
LABEL "alpha.talos.dev/version" = " ${ VERSION } "
2022-03-23 20:02:22 +03:00
LABEL org.opencontainers.image.source https://github.com/siderolabs/talos
2019-11-01 07:55:58 +03:00
ENTRYPOINT [ "/bin/installer" ]
2019-11-04 09:28:10 +03:00
ONBUILD RUN apk add --no-cache --update \
cpio \
squashfs-tools \
xz
2019-10-31 01:52:36 +03:00
ONBUILD WORKDIR /initramfs
ONBUILD ARG RM
2021-04-16 14:33:34 +03:00
ONBUILD RUN xz -d /usr/install/${ TARGETARCH } /initramfs.xz \
2021-06-20 18:51:20 +03:00
&& cpio -idvm < /usr/install/${ TARGETARCH } /initramfs \
2019-10-31 01:52:36 +03:00
&& unsquashfs -f -d /rootfs rootfs.sqsh \
&& for f in ${ RM } ; do rm -rfv /rootfs$f ; done \
2021-06-20 18:51:20 +03:00
&& rm /usr/install/${ TARGETARCH } /initramfs \
2019-10-31 01:52:36 +03:00
&& rm rootfs.sqsh
ONBUILD COPY --from= customization / /rootfs
ONBUILD RUN find /rootfs \
&& mksquashfs /rootfs rootfs.sqsh -all-root -noappend -comp xz -Xdict-size 100% -no-progress \
2021-04-16 14:33:34 +03:00
&& set -o pipefail && find . 2>/dev/null | cpio -H newc -o | xz -v -C crc32 -0 -e -T 0 -z >/usr/install/${ TARGETARCH } /initramfs.xz \
2019-10-31 01:52:36 +03:00
&& rm -rf /rootfs \
&& rm -rf /initramfs
ONBUILD WORKDIR /
2019-07-13 03:24:51 +03:00
2021-12-03 14:18:59 +03:00
FROM installer AS imager
2019-07-13 03:24:51 +03:00
# The test target performs tests on the source code.
2019-08-09 06:45:13 +03:00
FROM base AS unit-tests-runner
2019-07-13 03:24:51 +03:00
RUN unlink /etc/ssl
2019-07-21 21:27:15 +03:00
COPY --from= rootfs / /
2019-07-23 17:17:16 +03:00
ARG TESTPKGS
2021-03-25 00:20:44 +03:00
ENV PLATFORM container
2021-11-23 19:04:41 +03:00
ARG GO_LDFLAGS
RUN --security= insecure --mount= type = cache,id= testspace,target= /tmp --mount= type = cache,target= /.cache go test -v \
-ldflags " ${ GO_LDFLAGS } " \
-covermode= atomic -coverprofile= coverage.txt -coverpkg= ${ TESTPKGS } -count 1 -p 4 ${ TESTPKGS }
2019-08-09 06:45:13 +03:00
FROM scratch AS unit-tests
COPY --from= unit-tests-runner /src/coverage.txt /coverage.txt
2019-07-13 03:24:51 +03:00
2019-08-09 06:45:13 +03:00
# The unit-tests-race target performs tests with race detector.
2019-08-07 01:08:27 +03:00
2020-05-22 23:26:56 +03:00
FROM base AS unit-tests-race
RUN unlink /etc/ssl
COPY --from= rootfs / /
2019-08-07 01:08:27 +03:00
ARG TESTPKGS
2021-03-25 00:20:44 +03:00
ENV PLATFORM container
ENV CGO_ENABLED 1
2021-11-23 19:04:41 +03:00
ARG GO_LDFLAGS
RUN --security= insecure --mount= type = cache,id= testspace,target= /tmp --mount= type = cache,target= /.cache go test -v \
-ldflags " ${ GO_LDFLAGS } " \
-race -count 1 -p 4 ${ TESTPKGS }
2019-08-07 01:08:27 +03:00
2021-03-26 12:58:20 +03:00
# The integration-test targets builds integration test binary.
2019-10-25 22:57:52 +03:00
2020-01-05 00:19:34 +03:00
FROM base AS integration-test-linux-build
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go test -v -c ${ GO_BUILDFLAGS } \
2021-03-29 17:27:23 +03:00
-ldflags " ${ GO_LDFLAGS } " \
2019-11-06 14:32:07 +03:00
-tags integration,integration_api,integration_cli,integration_k8s \
2019-10-25 22:57:52 +03:00
./internal/integration
2020-01-05 00:19:34 +03:00
FROM scratch AS integration-test-linux
COPY --from= integration-test-linux-build /src/integration.test /integration-test-linux-amd64
FROM base AS integration-test-darwin-build
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = darwin GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go test -v -c ${ GO_BUILDFLAGS } \
2021-03-29 17:27:23 +03:00
-ldflags " ${ GO_LDFLAGS } " \
2020-01-05 00:19:34 +03:00
-tags integration,integration_api,integration_cli,integration_k8s \
./internal/integration
FROM scratch AS integration-test-darwin
COPY --from= integration-test-darwin-build /src/integration.test /integration-test-darwin-amd64
2019-10-25 22:57:52 +03:00
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
# The integration-test-provision target builds integration test binary with provisioning tests.
FROM base AS integration-test-provision-linux-build
2021-03-29 17:27:23 +03:00
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
2022-04-11 20:25:11 +03:00
ARG GOAMD64
RUN --mount= type = cache,target= /.cache GOOS = linux GOARCH = amd64 GOAMD64 = ${ GOAMD64 } go test -v -c ${ GO_BUILDFLAGS } \
2021-03-29 17:27:23 +03:00
-ldflags " ${ GO_LDFLAGS } " \
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
-tags integration,integration_provision \
./internal/integration
FROM scratch AS integration-test-provision-linux
COPY --from= integration-test-provision-linux-build /src/integration.test /integration-test-provision-linux-amd64
2019-07-13 03:24:51 +03:00
# The lint target performs linting on the source code.
2019-12-24 20:28:58 +03:00
FROM base AS lint-go
2020-02-18 03:45:30 +03:00
COPY .golangci.yml .
2021-03-25 00:20:44 +03:00
ENV GOGC 50
2021-03-25 23:53:05 +03:00
ENV GOLANGCI_LINT_CACHE /.cache/lint
2021-03-25 00:20:44 +03:00
RUN --mount= type = cache,target= /.cache golangci-lint run --config .golangci.yml
2020-08-17 19:12:47 +03:00
WORKDIR /src/pkg/machinery
2021-03-25 00:20:44 +03:00
RUN --mount= type = cache,target= /.cache golangci-lint run --config ../../.golangci.yml
2020-08-17 19:12:47 +03:00
WORKDIR /src
2021-03-25 00:20:44 +03:00
RUN --mount= type = cache,target= /.cache importvet github.com/talos-systems/talos/...
2019-08-17 11:51:40 +03:00
2020-04-29 07:10:19 +03:00
# The protolint target performs linting on protobuf files.
2019-08-28 00:45:59 +03:00
2019-12-24 20:28:58 +03:00
FROM base AS lint-protobuf
2020-04-29 07:10:19 +03:00
WORKDIR /src/api
COPY api .
2021-11-29 20:45:31 +03:00
RUN --mount= type = cache,target= /.cache prototool lint --protoc-bin-path= /toolchain/bin/protoc --protoc-wkt-path= /toolchain/include
RUN --mount= type = cache,target= /.cache prototool break check --descriptor-set-path= api.descriptors --protoc-bin-path= /toolchain/bin/protoc --protoc-wkt-path= /toolchain/include
2019-08-28 00:45:59 +03:00
2019-08-17 11:51:40 +03:00
# The markdownlint target performs linting on Markdown files.
2022-06-20 17:40:43 +03:00
FROM node:18.4.0-alpine AS lint-markdown
2020-11-04 08:52:06 +03:00
RUN apk add --no-cache findutils
2020-07-23 21:21:42 +03:00
RUN npm i -g markdownlint-cli@0.23.2
RUN npm i -g textlint@11.7.6
2021-05-19 15:44:46 +03:00
RUN npm i -g textlint-filter-rule-comments@1.2.2
2020-05-06 18:40:07 +03:00
RUN npm i -g textlint-rule-one-sentence-per-line@1.0.2
2019-08-17 11:51:40 +03:00
WORKDIR /src
2020-04-27 06:07:08 +03:00
COPY . .
2020-11-04 08:52:06 +03:00
RUN markdownlint \
--ignore '**/LICENCE.md' \
--ignore '**/CHANGELOG.md' \
--ignore '**/CODE_OF_CONDUCT.md' \
--ignore '**/node_modules/**' \
--ignore '**/hack/chglog/**' \
2022-03-18 15:45:03 +03:00
--ignore 'website/content/*/reference/*' \
--ignore 'website/themes/**' \
2021-05-19 15:44:46 +03:00
.
2020-11-04 08:52:06 +03:00
RUN find . \
-name '*.md' \
-not -path './LICENCE.md' \
-not -path './CHANGELOG.md' \
-not -path './CODE_OF_CONDUCT.md' \
-not -path '*/node_modules/*' \
-not -path './hack/chglog/**' \
2022-03-18 15:45:03 +03:00
-not -path './website/content/*/reference/*' \
-not -path './website/themes/**' \
2021-05-19 15:44:46 +03:00
-print0 \
| xargs -0 textlint
2019-12-24 23:23:52 +03:00
# The docs target generates documentation.
FROM base AS docs-build
2020-08-17 19:12:47 +03:00
WORKDIR /src
2020-03-21 03:38:48 +03:00
COPY --from= talosctl-linux /talosctl-linux-amd64 /bin/talosctl
2020-10-23 05:39:37 +03:00
RUN env HOME = /home/user TAG = latest /bin/talosctl docs --config /tmp \
&& env HOME = /home/user TAG = latest /bin/talosctl docs --cli /tmp
FROM pseudomuto/protoc-gen-doc as proto-docs-build
COPY --from= generate-build /api /protos
COPY ./hack/protoc-gen-doc/markdown.tmpl /tmp/markdown.tmpl
RUN protoc \
-I/protos \
-I/protos/common \
2021-01-19 15:45:50 +03:00
-I/protos/inspect \
2020-10-23 05:39:37 +03:00
-I/protos/machine \
2021-01-12 15:52:24 +03:00
-I/protos/resource \
2020-10-23 05:39:37 +03:00
-I/protos/security \
2020-11-11 20:17:46 +03:00
-I/protos/storage \
2020-10-23 05:39:37 +03:00
-I/protos/time \
2020-12-23 18:08:12 +03:00
-I/protos/vendor \
2020-10-23 05:39:37 +03:00
--doc_opt= /tmp/markdown.tmpl,api.md \
--doc_out= /tmp \
2020-12-23 18:08:12 +03:00
/protos/common/*.proto \
2021-01-19 15:45:50 +03:00
/protos/inspect/*.proto \
2020-10-23 05:39:37 +03:00
/protos/machine/*.proto \
2021-01-12 15:52:24 +03:00
/protos/resource/*.proto \
2020-10-23 05:39:37 +03:00
/protos/security/*.proto \
2020-11-11 20:17:46 +03:00
/protos/storage/*.proto \
2020-10-23 05:39:37 +03:00
/protos/time/*.proto
2019-12-24 23:23:52 +03:00
FROM scratch AS docs
2022-06-10 21:21:39 +03:00
COPY --from= docs-build /tmp/configuration.md /website/content/v1.2/reference/
COPY --from= docs-build /tmp/cli.md /website/content/v1.2/reference/
COPY --from= proto-docs-build /tmp/api.md /website/content/v1.2/reference/
2020-10-30 01:08:05 +03:00
# The talosctl-cni-bundle builds the CNI bundle for talosctl.
FROM scratch AS talosctl-cni-bundle
ARG TARGETARCH
COPY --from= extras-talosctl-cni-bundle-install /opt/cni/bin/ /talosctl-cni-bundle-${ TARGETARCH } /
2022-05-31 21:42:11 +03:00
# The go-mod-outdated target lists all outdated modules.
FROM base AS go-mod-outdated
RUN --mount= type = cache,target= /.cache go install github.com/psampaz/go-mod-outdated@latest \
&& mv /go/bin/go-mod-outdated /toolchain/go/bin/go-mod-outdated
COPY ./hack/cloud-image-uploader ./hack/cloud-image-uploader
# fail always to get the output back
RUN --mount= type = cache,target= /.cache cd pkg/machinery && \
echo -e "\n>>>> pkg/machinery:" && \
( go list -u -m -json all | go-mod-outdated -update -direct) && \
cd ../.. && \
echo -e "\n>>>> .:" && \
( go list -u -m -json all | go-mod-outdated -update -direct) && \
cd hack/cloud-image-uploader && \
echo -e "\n>>>> hack/cloud-image-uploader:" && \
( go list -u -m -json all | go-mod-outdated -update -direct) && \
exit 1