2019-08-01 00:47:55 +03:00
# syntax = docker/dockerfile-upstream:1.1.2-experimental
2019-07-06 06:20:24 +00:00
2019-08-07 01:08:27 +03:00
# Meta args applied to stage base names.
2019-07-13 00:24:51 +00:00
ARG TOOLS
2019-08-07 01:08:27 +03:00
ARG GO_VERSION
# The tools target provides base toolchain for the build.
2019-07-13 00:24:51 +00:00
FROM $TOOLS AS tools
2019-09-10 18:12:28 +00:00
ENV PATH /toolchain/bin:/toolchain/go/bin
2019-07-13 00:24:51 +00: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" ]
2020-02-26 22:27:34 +03:00
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /toolchain/bin v1.23.6
2019-09-10 18:12:28 +00:00
RUN cd $( mktemp -d) \
&& go mod init tmp \
2020-03-19 14:26:19 -04:00
&& go get mvdan.cc/gofumpt/gofumports@aaa7156f4122b1055c466e26e77812fa32bac1d9 \
2019-09-12 14:32:42 +00:00
&& mv /go/bin/gofumports /toolchain/go/bin/gofumports
2019-08-27 21:45:59 +00:00
RUN curl -sfL https://github.com/uber/prototool/releases/download/v1.8.0/prototool-Linux-x86_64.tar.gz | tar -xz --strip-components= 2 -C /toolchain/bin prototool/bin/prototool
2019-11-09 15:22:43 +00:00
COPY ./hack/docgen /go/src/github.com/talos-systems/docgen
RUN cd /go/src/github.com/talos-systems/docgen \
&& go build . \
&& mv docgen /toolchain/go/bin/
2019-07-13 00:24:51 +00:00
# The build target creates a container that will be used to build Talos source
# code.
FROM scratch AS build
COPY --from= tools / /
SHELL [ "/toolchain/bin/bash" , "-c" ]
ENV PATH /toolchain/bin:/toolchain/go/bin
ENV GO111MODULE on
ENV GOPROXY https://proxy.golang.org
ENV CGO_ENABLED 0
WORKDIR /src
2018-12-19 22:22:05 -08:00
2019-07-13 00:24:51 +00:00
# The generate target generates code from protobuf service definitions.
2019-01-18 06:26:12 -08:00
2019-07-13 00:24:51 +00:00
FROM build AS generate-build
2019-10-23 21:31:18 -05:00
# Common needs to be at or near the top to satisfy the subsequent imports
2019-10-21 13:21:46 -05:00
COPY ./api/common/common.proto /api/common/common.proto
2019-12-29 15:33:05 -06:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api common/common.proto
2020-01-22 22:14:58 +00:00
COPY ./api/health/health.proto /api/health/health.proto
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api health/health.proto
2019-10-21 13:21:46 -05:00
COPY ./api/os/os.proto /api/os/os.proto
2019-12-29 15:33:05 -06:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api os/os.proto
2019-10-21 13:21:46 -05:00
COPY ./api/security/security.proto /api/security/security.proto
2019-12-29 15:33:05 -06:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api security/security.proto
2019-10-21 13:21:46 -05:00
COPY ./api/machine/machine.proto /api/machine/machine.proto
2019-12-29 15:33:05 -06:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api machine/machine.proto
2019-10-21 13:21:46 -05:00
COPY ./api/time/time.proto /api/time/time.proto
2019-12-29 15:33:05 -06:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api time/time.proto
2019-10-21 13:21:46 -05:00
COPY ./api/network/network.proto /api/network/network.proto
2019-12-29 15:33:05 -06:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api network/network.proto
2019-11-09 00:08:38 +03:00
# Gofumports generated files to adjust import order
RUN gofumports -w -local github.com/talos-systems/talos /api/
2019-07-21 18:27:15 +00:00
2019-07-13 00:24:51 +00:00
FROM scratch AS generate
2019-12-29 15:33:05 -06:00
COPY --from= generate-build /api/common/common.pb.go /api/common/
2020-01-22 22:14:58 +00:00
COPY --from= generate-build /api/health/health.pb.go /api/health/
2019-12-29 15:33:05 -06:00
COPY --from= generate-build /api/os/os.pb.go /api/os/
COPY --from= generate-build /api/security/security.pb.go /api/security/
COPY --from= generate-build /api/machine/machine.pb.go /api/machine/
COPY --from= generate-build /api/time/time.pb.go /api/time/
COPY --from= generate-build /api/network/network.pb.go /api/network/
2019-03-28 02:33:03 +03:00
2019-07-13 00:24:51 +00:00
# The base target provides a container that can be used to build all Talos
# assets.
2019-01-18 06:26:12 -08:00
2019-07-13 00:24:51 +00:00
FROM build AS base
2019-01-19 01:58:26 -08:00
COPY ./go.mod ./
COPY ./go.sum ./
2018-12-19 22:22:05 -08:00
RUN go mod download
RUN go mod verify
2019-04-11 02:50:56 +03:00
COPY ./cmd ./cmd
COPY ./pkg ./pkg
COPY ./internal ./internal
2019-09-16 19:32:45 +00:00
COPY --from= generate /api ./api
2019-04-17 23:25:22 +03:00
RUN go list -mod= readonly all >/dev/null
2019-06-22 07:18:08 +03:00
RUN ! go mod tidy -v 2>& 1 | grep .
2018-12-19 22:22:05 -08:00
2019-07-13 00:24:51 +00:00
# The init target builds the init binary.
FROM base AS init-build
ARG SHA
ARG TAG
2019-08-01 23:01:31 +00:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-13 00:24:51 +00:00
WORKDIR /src/internal/app/init
2019-07-26 20:21:45 +03:00
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Talos -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /init
2019-07-13 00:24:51 +00:00
RUN chmod +x /init
2019-07-21 18:27:15 +00:00
2019-07-13 00:24:51 +00:00
FROM scratch AS init
COPY --from= init-build /init /init
2019-07-16 15:09:35 +00:00
# The machined target builds the machined image.
FROM base AS machined-build
ARG SHA
ARG TAG
2019-08-01 23:01:31 +00:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-16 15:09:35 +00:00
WORKDIR /src/internal/app/machined
2019-07-27 08:09:50 +00:00
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Talos -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /machined
2019-07-16 15:09:35 +00:00
RUN chmod +x /machined
2019-07-21 18:27:15 +00:00
2019-07-16 15:09:35 +00:00
FROM scratch AS machined
COPY --from= machined-build /machined /machined
2019-07-13 00:24:51 +00:00
# The ntpd target builds the ntpd image.
FROM base AS ntpd-build
ARG SHA
ARG TAG
2019-08-01 23:01:31 +00:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-13 00:24:51 +00:00
WORKDIR /src/internal/app/ntpd
2019-07-26 20:21:45 +03:00
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Server -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /ntpd
2019-07-13 00:24:51 +00:00
RUN chmod +x /ntpd
2019-07-21 18:27:15 +00:00
2020-02-14 15:26:44 +03:00
FROM base AS ntpd-image
ARG TAG
ARG USERNAME
COPY --from= ntpd-build /ntpd /scratch/ntpd
WORKDIR /scratch
RUN printf "FROM scratch\nCOPY ./ntpd /ntpd\nENTRYPOINT [\"/ntpd\"]" > Dockerfile
RUN --security= insecure img build --tag ${ USERNAME } /ntpd:${ TAG } --output type = docker,dest= /ntpd.tar --no-console .
2019-07-13 00:24:51 +00:00
2019-10-23 21:31:18 -05:00
# The apid target builds the api image.
FROM base AS apid-build
ARG SHA
ARG TAG
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
WORKDIR /src/internal/app/apid
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Server -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /apid
RUN chmod +x /apid
2020-02-14 15:26:44 +03:00
FROM base AS apid-image
ARG TAG
ARG USERNAME
COPY --from= apid-build /apid /scratch/apid
WORKDIR /scratch
RUN printf "FROM scratch\nCOPY ./apid /apid\nENTRYPOINT [\"/apid\"]" > Dockerfile
RUN --security= insecure img build --tag ${ USERNAME } /apid:${ TAG } --output type = docker,dest= /apid.tar --no-console .
2019-10-23 21:31:18 -05:00
2019-07-13 00:24:51 +00:00
# The osd target builds the osd image.
2018-12-19 22:22:05 -08:00
2019-04-18 19:31:43 -07:00
FROM base AS osd-build
2018-12-19 22:22:05 -08:00
ARG SHA
ARG TAG
2019-08-01 23:01:31 +00:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2018-12-19 22:22:05 -08:00
WORKDIR /src/internal/app/osd
2019-07-26 20:21:45 +03:00
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Server -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /osd
2018-12-19 22:22:05 -08:00
RUN chmod +x /osd
2019-07-21 18:27:15 +00:00
2020-02-14 15:26:44 +03:00
FROM base AS osd-image
ARG TAG
ARG USERNAME
COPY --from= osd-build /osd /scratch/osd
WORKDIR /scratch
RUN printf "FROM scratch\nCOPY ./osd /osd\nENTRYPOINT [\"/osd\"]" > Dockerfile
RUN --security= insecure img build --tag ${ USERNAME } /osd:${ TAG } --output type = docker,dest= /osd.tar --no-console .
2018-12-19 22:22:05 -08:00
2019-04-18 19:31:43 -07:00
# The trustd target builds the trustd image.
2019-01-18 06:26:12 -08:00
2019-04-18 19:31:43 -07:00
FROM base AS trustd-build
2018-12-19 22:22:05 -08:00
ARG SHA
ARG TAG
2019-08-01 23:01:31 +00:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2018-12-19 22:22:05 -08:00
WORKDIR /src/internal/app/trustd
2019-07-26 20:21:45 +03:00
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Server -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /trustd
2018-12-19 22:22:05 -08:00
RUN chmod +x /trustd
2019-07-21 18:27:15 +00:00
2020-02-14 15:26:44 +03:00
FROM base AS trustd-image
ARG TAG
ARG USERNAME
COPY --from= trustd-build /trustd /scratch/trustd
WORKDIR /scratch
RUN printf "FROM scratch\nCOPY ./trustd /trustd\nENTRYPOINT [\"/trustd\"]" > Dockerfile
RUN --security= insecure img build --tag ${ USERNAME } /trustd:${ TAG } --output type = docker,dest= /trustd.tar --no-console .
2018-12-19 22:22:05 -08:00
2019-08-02 16:08:24 -05:00
# The networkd target builds the networkd image.
FROM base AS networkd-build
ARG SHA
ARG TAG
ARG VERSION_PKG = "github.com/talos-systems/talos/internal/pkg/version"
WORKDIR /src/internal/app/networkd
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Server -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /networkd
RUN chmod +x /networkd
2020-02-14 15:26:44 +03:00
FROM base AS networkd-image
ARG TAG
ARG USERNAME
COPY --from= networkd-build /networkd /scratch/networkd
WORKDIR /scratch
RUN printf "FROM scratch\nCOPY ./networkd /networkd\nENTRYPOINT [\"/networkd\"]" > Dockerfile
RUN --security= insecure img build --tag ${ USERNAME } /networkd:${ TAG } --output type = docker,dest= /networkd.tar --no-console .
2020-03-04 22:25:27 +03:00
# The routerd target builds the routerd image.
FROM base AS routerd-build
ARG SHA
ARG TAG
ARG VERSION_PKG = "github.com/talos-systems/talos/internal/pkg/version"
WORKDIR /src/internal/app/routerd
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Server -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /routerd
RUN chmod +x /routerd
FROM base AS routerd-image
ARG TAG
ARG USERNAME
COPY --from= routerd-build /routerd /scratch/routerd
WORKDIR /scratch
RUN printf "FROM scratch\nCOPY ./routerd /routerd\nENTRYPOINT [\"/routerd\"]" > Dockerfile
RUN --security= insecure img build --tag ${ USERNAME } /routerd:${ TAG } --output type = docker,dest= /routerd.tar --no-console .
2019-08-02 16:08:24 -05:00
2020-03-20 17:38:48 -07:00
# The talosctl targets build the talosctl binaries.
2019-01-18 06:26:12 -08:00
2020-03-21 14:27:03 -07:00
FROM base AS talosctl-linux-amd64-build
2018-12-19 22:22:05 -08:00
ARG SHA
ARG TAG
2019-12-27 20:49:24 +00:00
ARG ARTIFACTS
2019-08-01 23:01:31 +00:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2020-03-20 17:38:48 -07:00
ARG MGMT_HELPERS_PKG = "github.com/talos-systems/talos/cmd/talosctl/pkg/mgmt/helpers"
WORKDIR /src/cmd/talosctl
RUN --mount= type = cache,target= /.cache/go-build GOOS = linux GOARCH = amd64 go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Client -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } -X ${ MGMT_HELPERS_PKG } .ArtifactsPath= ${ ARTIFACTS } " -o /talosctl-linux-amd64
RUN chmod +x /talosctl-linux-amd64
2019-07-21 18:27:15 +00:00
2020-03-21 14:27:03 -07:00
FROM base AS talosctl-linux-arm64-build
ARG SHA
ARG TAG
ARG ARTIFACTS
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
ARG MGMT_HELPERS_PKG = "github.com/talos-systems/talos/cmd/talosctl/pkg/mgmt/helpers"
WORKDIR /src/cmd/talosctl
RUN --mount= type = cache,target= /.cache/go-build GOOS = linux GOARCH = arm64 go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Client -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } -X ${ MGMT_HELPERS_PKG } .ArtifactsPath= ${ ARTIFACTS } " -o /talosctl-linux-arm64
RUN chmod +x /talosctl-linux-arm64
2020-03-21 18:08:09 -07:00
FROM base AS talosctl-linux-armv7-build
ARG SHA
ARG TAG
ARG ARTIFACTS
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
ARG MGMT_HELPERS_PKG = "github.com/talos-systems/talos/cmd/talosctl/pkg/mgmt/helpers"
WORKDIR /src/cmd/talosctl
RUN --mount= type = cache,target= /.cache/go-build GOOS = linux GOARCH = arm GOARM = 7 go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Client -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } -X ${ MGMT_HELPERS_PKG } .ArtifactsPath= ${ ARTIFACTS } " -o /talosctl-linux-armv7
RUN chmod +x /talosctl-linux-armv7
2020-03-20 17:38:48 -07:00
FROM scratch AS talosctl-linux
2020-03-21 14:27:03 -07: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-21 18:08:09 -07:00
COPY --from= talosctl-linux-armv7-build /talosctl-linux-armv7 /talosctl-linux-armv7
2019-04-18 19:31:43 -07:00
2020-03-20 17:38:48 -07:00
FROM base AS talosctl-darwin-build
2019-04-18 19:31:43 -07:00
ARG SHA
ARG TAG
2019-12-27 20:49:24 +00:00
ARG ARTIFACTS
2019-08-01 23:01:31 +00:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2020-03-20 17:38:48 -07:00
ARG MGMT_HELPERS_PKG = "github.com/talos-systems/talos/cmd/talosctl/pkg/mgmt/helpers"
WORKDIR /src/cmd/talosctl
RUN --mount= type = cache,target= /.cache/go-build GOOS = darwin GOARCH = amd64 go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Client -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } -X ${ MGMT_HELPERS_PKG } .ArtifactsPath= ${ ARTIFACTS } " -o /talosctl-darwin-amd64
RUN chmod +x /talosctl-darwin-amd64
2019-07-21 18:27:15 +00:00
2020-03-20 17:38:48 -07:00
FROM scratch AS talosctl-darwin
COPY --from= talosctl-darwin-build /talosctl-darwin-amd64 /talosctl-darwin-amd64
2019-04-18 19:31:43 -07:00
# The kernel target is the linux kernel.
2019-07-13 00:24:51 +00:00
FROM scratch AS kernel
2020-03-24 11:38:23 -04:00
COPY --from= docker.io/autonomy/kernel:00d8397 /boot/vmlinuz /vmlinuz
COPY --from= docker.io/autonomy/kernel:00d8397 /boot/vmlinux /vmlinux
2019-04-18 19:31:43 -07:00
2019-07-21 18:27:15 +00:00
# The rootfs target provides the Talos rootfs.
2019-04-18 19:31:43 -07:00
2019-07-21 18:27:15 +00:00
FROM build AS rootfs-base
2020-03-24 11:38:23 -04:00
COPY --from= docker.io/autonomy/fhs:00d8397 / /rootfs
COPY --from= docker.io/autonomy/ca-certificates:00d8397 / /rootfs
COPY --from= docker.io/autonomy/containerd:00d8397 / /rootfs
COPY --from= docker.io/autonomy/dosfstools:00d8397 / /rootfs
COPY --from= docker.io/autonomy/eudev:00d8397 / /rootfs
COPY --from= docker.io/autonomy/iptables:00d8397 / /rootfs
COPY --from= docker.io/autonomy/libressl:00d8397 / /rootfs
COPY --from= docker.io/autonomy/libseccomp:00d8397 / /rootfs
COPY --from= docker.io/autonomy/musl:00d8397 / /rootfs
COPY --from= docker.io/autonomy/runc:00d8397 / /rootfs
COPY --from= docker.io/autonomy/socat:00d8397 / /rootfs
COPY --from= docker.io/autonomy/syslinux:00d8397 / /rootfs
COPY --from= docker.io/autonomy/xfsprogs:00d8397 / /rootfs
COPY --from= docker.io/autonomy/util-linux:00d8397 /lib/libblkid.* /rootfs/lib
COPY --from= docker.io/autonomy/util-linux:00d8397 /lib/libuuid.* /rootfs/lib
COPY --from= docker.io/autonomy/kmod:00d8397 /usr/lib/libkmod.* /rootfs/lib
COPY --from= docker.io/autonomy/kernel:00d8397 /lib/modules /rootfs/lib/modules
2019-07-21 18:27:15 +00:00
COPY --from= machined /machined /rootfs/sbin/init
2020-02-14 15:26:44 +03:00
COPY --from= apid-image /apid.tar /rootfs/usr/images/
COPY --from= ntpd-image /ntpd.tar /rootfs/usr/images/
COPY --from= osd-image /osd.tar /rootfs/usr/images/
COPY --from= trustd-image /trustd.tar /rootfs/usr/images/
COPY --from= networkd-image /networkd.tar /rootfs/usr/images/
2020-03-04 22:25:27 +03:00
COPY --from= routerd-image /routerd.tar /rootfs/usr/images/
2019-07-25 21:38:20 +00: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
2019-12-04 23:20:17 +00:00
COPY hack/containerd.toml /rootfs/etc/cri/containerd.toml
2019-07-21 18:27:15 +00:00
RUN touch /rootfs/etc/resolv.conf
RUN touch /rootfs/etc/hosts
RUN touch /rootfs/etc/os-release
2019-10-15 02:03:38 +00:00
RUN mkdir -pv /rootfs/{ boot,usr/local/share,mnt}
2019-07-21 18:27:15 +00:00
RUN mkdir -pv /rootfs/{ etc/kubernetes/manifests,etc/cni,usr/libexec/kubernetes}
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
2019-07-13 00:24:51 +00:00
2019-07-21 18:27:15 +00:00
FROM rootfs-base AS rootfs-squashfs
COPY --from= rootfs / /rootfs
2019-07-27 08:09:50 +00:00
RUN mksquashfs /rootfs /rootfs.sqsh -all-root -noappend -comp xz -Xdict-size 100% -no-progress
2019-04-18 19:31:43 -07:00
2019-10-30 22:52:36 +00:00
FROM scratch AS squashfs
COPY --from= rootfs-squashfs /rootfs.sqsh /
2019-04-18 19:31:43 -07:00
FROM scratch AS rootfs
2019-07-21 18:27:15 +00:00
COPY --from= rootfs-base /rootfs /
# The initramfs target provides the Talos initramfs image.
FROM build AS initramfs-archive
WORKDIR /initramfs
2019-10-30 22:52:36 +00:00
COPY --from= squashfs /rootfs.sqsh .
2019-07-21 18:27:15 +00:00
COPY --from= init /init .
RUN set -o pipefail && find . 2>/dev/null | cpio -H newc -o | xz -v -C crc32 -0 -e -T 0 -z >/initramfs.xz
FROM scratch AS initramfs
COPY --from= initramfs-archive /initramfs.xz /initramfs.xz
2019-04-18 19:31:43 -07:00
2019-12-24 12:23:52 -08:00
# The talos target generates a docker image that can be used to run Talos
2019-04-18 19:31:43 -07:00
# in containers.
2019-12-24 12:23:52 -08:00
FROM scratch AS talos
2019-07-21 18:27:15 +00:00
COPY --from= rootfs / /
ENTRYPOINT [ "/sbin/init" ]
2019-04-18 19:31:43 -07:00
2019-05-15 16:14:30 -07:00
# The installer target generates an image that can be used to install Talos to
# various environments.
2019-04-18 19:31:43 -07:00
2019-11-01 04:55:58 +00:00
FROM base AS installer-build
ARG SHA
ARG TAG
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
WORKDIR /src/cmd/installer
RUN --mount= type = cache,target= /.cache/go-build go build -ldflags " -s -w -X ${ VERSION_PKG } .Name=Talos -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " -o /installer
RUN chmod +x /installer
2019-04-18 19:31:43 -07:00
FROM alpine:3.8 AS installer
2019-10-30 22:52:36 +00:00
RUN apk add --no-cache --update \
2019-06-25 19:25:57 -07:00
bash \
2019-09-23 03:42:35 -07:00
ca-certificates \
2019-06-25 19:25:57 -07:00
cdrkit \
qemu-img \
syslinux \
util-linux \
2019-11-04 06:28:10 +00:00
xfsprogs
2019-05-15 16:14:30 -07:00
COPY --from= kernel /vmlinuz /usr/install/vmlinuz
2019-07-21 18:27:15 +00:00
COPY --from= rootfs /usr/lib/syslinux/ /usr/lib/syslinux
2019-05-15 16:14:30 -07:00
COPY --from= initramfs /initramfs.xz /usr/install/initramfs.xz
2019-11-01 04:55:58 +00:00
COPY --from= installer-build /installer /bin/installer
2020-03-20 17:38:48 -07:00
RUN ln -s /bin/installer /bin/talosctl
2019-04-18 19:31:43 -07:00
ARG TAG
ENV VERSION ${ TAG }
2019-12-29 19:43:40 -08:00
LABEL "alpha.talos.dev/version" = " ${ VERSION } "
2019-11-01 04:55:58 +00:00
ENTRYPOINT [ "/bin/installer" ]
2019-11-04 06:28:10 +00:00
ONBUILD RUN apk add --no-cache --update \
cpio \
squashfs-tools \
xz
2019-10-30 22:52:36 +00:00
ONBUILD WORKDIR /initramfs
ONBUILD ARG RM
ONBUILD RUN xz -d /usr/install/initramfs.xz \
&& cpio -idvm < /usr/install/initramfs \
&& unsquashfs -f -d /rootfs rootfs.sqsh \
&& for f in ${ RM } ; do rm -rfv /rootfs$f ; done \
&& rm /usr/install/initramfs \
&& 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 \
&& set -o pipefail && find . 2>/dev/null | cpio -H newc -o | xz -v -C crc32 -0 -e -T 0 -z >/usr/install/initramfs.xz \
&& rm -rf /rootfs \
&& rm -rf /initramfs
ONBUILD WORKDIR /
2019-07-13 00:24:51 +00:00
# The test target performs tests on the source code.
2019-08-09 03:45:13 +00:00
FROM base AS unit-tests-runner
2019-07-13 00:24:51 +00:00
RUN unlink /etc/ssl
2019-07-21 18:27:15 +00:00
COPY --from= rootfs / /
2019-07-13 00:24:51 +00:00
COPY hack/golang/test.sh /bin
2019-07-23 17:17:16 +03:00
ARG TESTPKGS
2019-07-26 20:21:45 +03:00
RUN --security= insecure --mount= type = cache,id= testspace,target= /tmp --mount= type = cache,target= /.cache/go-build /bin/test.sh ${ TESTPKGS }
2019-08-09 03:45:13 +00:00
FROM scratch AS unit-tests
COPY --from= unit-tests-runner /src/coverage.txt /coverage.txt
2019-07-13 00:24:51 +00:00
2019-08-09 03:45:13 +00:00
# The unit-tests-race target performs tests with race detector.
2019-08-07 01:08:27 +03:00
2019-08-09 03:45:13 +00:00
FROM golang:${GO_VERSION} AS unit-tests-race
2019-08-07 01:08:27 +03:00
COPY --from= base /src /src
COPY --from= base /go/pkg/mod /go/pkg/mod
WORKDIR /src
ENV GO111MODULE on
ARG TESTPKGS
2019-08-30 20:49:26 +03:00
RUN --mount= type = cache,target= /root/.cache/go-build go test -v -count 1 -race ${ TESTPKGS }
2019-08-07 01:08:27 +03:00
2019-10-25 22:57:52 +03:00
# The integration-test target builds integration test binary.
2020-01-04 13:19:34 -08:00
FROM base AS integration-test-linux-build
2019-10-25 22:57:52 +03:00
ARG SHA
ARG TAG
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
RUN --mount= type = cache,target= /.cache/go-build GOOS = linux GOARCH = amd64 go test -c \
-ldflags " -s -w -X ${ VERSION_PKG } .Name=Client -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " \
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-04 13:19:34 -08: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
ARG SHA
ARG TAG
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
RUN --mount= type = cache,target= /.cache/go-build GOOS = darwin GOARCH = amd64 go test -c \
-ldflags " -s -w -X ${ VERSION_PKG } .Name=Client -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } " \
-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
ARG SHA
ARG TAG
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2020-03-20 17:38:48 -07:00
ARG MGMT_HELPERS_PKG = "github.com/talos-systems/talos/cmd/talosctl/pkg/mgmt/helpers"
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
ARG ARTIFACTS
RUN --mount= type = cache,target= /.cache/go-build GOOS = linux GOARCH = amd64 go test -c \
2020-03-04 00:37:18 +03:00
-ldflags " -s -w -X ${ VERSION_PKG } .Name=Client -X ${ VERSION_PKG } .SHA= ${ SHA } -X ${ VERSION_PKG } .Tag= ${ TAG } -X ${ MGMT_HELPERS_PKG } .ArtifactsPath= ${ ARTIFACTS } " \
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 00:24:51 +00:00
# The lint target performs linting on the source code.
2019-12-24 09:28:58 -08:00
FROM base AS lint-go
2020-02-17 16:45:30 -08:00
COPY .golangci.yml .
2019-09-12 00:58:51 +03:00
ENV GOGC = 50
2020-02-17 16:45:30 -08:00
RUN --mount= type = cache,target= /.cache/go-build golangci-lint run --config .golangci.yml
2019-09-10 18:12:28 +00:00
RUN find . -name '*.pb.go' | xargs rm
2019-09-12 14:32:42 +00:00
RUN FILES = " $( gofumports -l -local github.com/talos-systems/talos .) " && test -z " ${ FILES } " || ( echo -e " Source code is not formatted with 'gofumports -w -local github.com/talos-systems/talos .':\n ${ FILES } " ; exit 1)
2019-08-17 08:51:40 +00:00
2019-08-27 21:45:59 +00:00
# The protolint target performs linting on Markdown files.
2019-12-24 09:28:58 -08:00
FROM base AS lint-protobuf
2019-08-27 21:45:59 +00:00
COPY prototool.yaml /src
RUN prototool lint --protoc-bin-path= /toolchain/bin/protoc --protoc-wkt-path= /toolchain/include .
2019-08-17 08:51:40 +00:00
# The markdownlint target performs linting on Markdown files.
2019-12-24 09:28:58 -08:00
FROM node:8.16.1-alpine AS lint-markdown
2019-08-17 08:51:40 +00:00
RUN npm install -g markdownlint-cli
2019-08-17 16:55:48 +00:00
RUN npm i sentences-per-line
2019-08-17 08:51:40 +00:00
WORKDIR /src
COPY .markdownlint.json .
COPY docs .
2019-08-17 16:55:48 +00:00
RUN markdownlint --rules /node_modules/sentences-per-line/index.js .
2019-12-24 12:23:52 -08:00
# The docs target generates documentation.
FROM base AS docs-build
RUN go generate ./pkg/config/types/v1alpha1
2020-03-20 17:38:48 -07:00
COPY --from= talosctl-linux /talosctl-linux-amd64 /bin/talosctl
RUN mkdir -p /docs/talosctl \
&& env HOME = /home/user TAG = latest /bin/talosctl docs /docs/talosctl
2019-12-24 12:23:52 -08:00
FROM scratch AS docs
2020-03-20 17:38:48 -07:00
COPY --from= docs-build /tmp/v1alpha1.md /docs/website/content/v0.4/en/configuration/v1alpha1.md
COPY --from= docs-build /docs/talosctl/* /docs/talosctl/