2019-08-01 00:47:55 +03:00
# syntax = docker/dockerfile-upstream:1.1.2-experimental
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
2019-08-07 01:08:27 +03:00
ARG GO_VERSION
# The tools target provides base toolchain for the build.
2019-07-13 03:24:51 +03:00
FROM $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" ]
2020-02-04 19:21:34 +03:00
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b /toolchain/bin v1.23.3
2019-09-10 21:12:28 +03:00
RUN cd $( mktemp -d) \
&& go mod init tmp \
2019-09-12 17:32:42 +03:00
&& go get mvdan.cc/gofumpt/gofumports \
&& mv /go/bin/gofumports /toolchain/go/bin/gofumports
2019-08-28 00:45:59 +03: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 18:22:43 +03: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 03:24:51 +03: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-20 09:22:05 +03:00
2019-07-13 03:24:51 +03:00
# The generate target generates code from protobuf service definitions.
2019-01-18 17:26:12 +03:00
2019-07-13 03:24:51 +03:00
FROM build AS generate-build
2019-10-24 05:31:18 +03:00
# Common needs to be at or near the top to satisfy the subsequent imports
2019-10-21 21:21:46 +03:00
COPY ./api/common/common.proto /api/common/common.proto
2019-12-30 00:33:05 +03:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api common/common.proto
2020-01-23 01:14:58 +03: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 21:21:46 +03:00
COPY ./api/os/os.proto /api/os/os.proto
2019-12-30 00:33:05 +03:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api os/os.proto
2019-10-21 21:21:46 +03:00
COPY ./api/security/security.proto /api/security/security.proto
2019-12-30 00:33:05 +03:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api security/security.proto
2019-10-21 21:21:46 +03:00
COPY ./api/machine/machine.proto /api/machine/machine.proto
2019-12-30 00:33:05 +03:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api machine/machine.proto
2019-10-21 21:21:46 +03:00
COPY ./api/time/time.proto /api/time/time.proto
2019-12-30 00:33:05 +03:00
RUN protoc -I/api --go_out= plugins = grpc,paths= source_relative:/api time/time.proto
2019-10-21 21:21:46 +03:00
COPY ./api/network/network.proto /api/network/network.proto
2019-12-30 00:33:05 +03: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 21:27:15 +03:00
2019-07-13 03:24:51 +03:00
FROM scratch AS generate
2019-12-30 00:33:05 +03:00
COPY --from= generate-build /api/common/common.pb.go /api/common/
2020-01-23 01:14:58 +03:00
COPY --from= generate-build /api/health/health.pb.go /api/health/
2019-12-30 00:33:05 +03: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 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
2019-07-13 03:24:51 +03:00
FROM build AS base
2019-01-19 12:58:26 +03:00
COPY ./go.mod ./
COPY ./go.sum ./
2018-12-20 09:22:05 +03: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 22:32:45 +03: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-20 09:22:05 +03:00
2019-07-13 03:24:51 +03:00
# The init target builds the init binary.
FROM base AS init-build
ARG SHA
ARG TAG
2019-08-02 02:01:31 +03:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-13 03:24:51 +03: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 03:24:51 +03:00
RUN chmod +x /init
2019-07-21 21:27:15 +03:00
2019-07-13 03:24:51 +03:00
FROM scratch AS init
COPY --from= init-build /init /init
2019-07-16 18:09:35 +03:00
# The machined target builds the machined image.
FROM base AS machined-build
ARG SHA
ARG TAG
2019-08-02 02:01:31 +03:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-16 18:09:35 +03:00
WORKDIR /src/internal/app/machined
2019-07-27 11:09:50 +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 /machined
2019-07-16 18:09:35 +03:00
RUN chmod +x /machined
2019-07-21 21:27:15 +03:00
2019-07-16 18:09:35 +03:00
FROM scratch AS machined
COPY --from= machined-build /machined /machined
2019-07-13 03:24:51 +03:00
# The ntpd target builds the ntpd image.
FROM base AS ntpd-build
ARG SHA
ARG TAG
2019-08-02 02:01:31 +03:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-13 03:24:51 +03: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 03:24:51 +03:00
RUN chmod +x /ntpd
2019-07-21 21:27:15 +03:00
2019-07-13 03:24:51 +03:00
FROM scratch AS ntpd
COPY --from= ntpd-build /ntpd /ntpd
ENTRYPOINT [ "/ntpd" ]
2019-10-24 05:31:18 +03: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
FROM scratch AS apid
COPY --from= apid-build /apid /apid
ENTRYPOINT [ "/apid" ]
2019-07-13 03:24:51 +03:00
# The osd target builds the osd image.
2018-12-20 09:22:05 +03:00
2019-04-19 05:31:43 +03:00
FROM base AS osd-build
2018-12-20 09:22:05 +03:00
ARG SHA
ARG TAG
2019-08-02 02:01:31 +03:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2018-12-20 09:22:05 +03: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-20 09:22:05 +03:00
RUN chmod +x /osd
2019-07-21 21:27:15 +03:00
2018-12-20 09:22:05 +03:00
FROM scratch AS osd
COPY --from= osd-build /osd /osd
ENTRYPOINT [ "/osd" ]
2019-04-19 05:31:43 +03:00
# The trustd target builds the trustd image.
2019-01-18 17:26:12 +03:00
2019-04-19 05:31:43 +03:00
FROM base AS trustd-build
2018-12-20 09:22:05 +03:00
ARG SHA
ARG TAG
2019-08-02 02:01:31 +03:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2018-12-20 09:22:05 +03: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-20 09:22:05 +03:00
RUN chmod +x /trustd
2019-07-21 21:27:15 +03:00
2018-12-20 09:22:05 +03:00
FROM scratch AS trustd
COPY --from= trustd-build /trustd /trustd
ENTRYPOINT [ "/trustd" ]
2019-08-03 00:08:24 +03: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
FROM scratch AS networkd
COPY --from= networkd-build /networkd /networkd
ENTRYPOINT [ "/networkd" ]
2019-07-13 03:24:51 +03:00
# The osctl targets build the osctl binaries.
2019-01-18 17:26:12 +03:00
2019-07-13 03:24:51 +03:00
FROM base AS osctl-linux-build
2018-12-20 09:22:05 +03:00
ARG SHA
ARG TAG
2019-12-27 23:49:24 +03:00
ARG ARTIFACTS
2019-08-02 02:01:31 +03:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-13 03:24:51 +03:00
WORKDIR /src/cmd/osctl
2019-12-27 23:49:24 +03:00
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 github.com/talos-systems/talos/cmd/osctl/pkg/helpers.ArtifactsPath= ${ ARTIFACTS } " -o /osctl-linux-amd64
2019-07-13 03:24:51 +03:00
RUN chmod +x /osctl-linux-amd64
2019-07-21 21:27:15 +03:00
2019-07-13 03:24:51 +03:00
FROM scratch AS osctl-linux
COPY --from= osctl-linux-build /osctl-linux-amd64 /osctl-linux-amd64
2019-04-19 05:31:43 +03:00
2019-07-13 03:24:51 +03:00
FROM base AS osctl-darwin-build
2019-04-19 05:31:43 +03:00
ARG SHA
ARG TAG
2019-12-27 23:49:24 +03:00
ARG ARTIFACTS
2019-08-02 02:01:31 +03:00
ARG VERSION_PKG = "github.com/talos-systems/talos/pkg/version"
2019-07-13 03:24:51 +03:00
WORKDIR /src/cmd/osctl
2019-12-27 23:49:24 +03:00
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 github.com/talos-systems/talos/cmd/osctl/pkg/helpers.ArtifactsPath= ${ ARTIFACTS } " -o /osctl-darwin-amd64
2019-07-13 03:24:51 +03:00
RUN chmod +x /osctl-darwin-amd64
2019-07-21 21:27:15 +03:00
2019-07-13 03:24:51 +03:00
FROM scratch AS osctl-darwin
COPY --from= osctl-darwin-build /osctl-darwin-amd64 /osctl-darwin-amd64
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-02-14 22:33:40 +03:00
COPY --from= docker.io/autonomy/kernel:f2a8e95 /boot/vmlinuz /vmlinuz
COPY --from= docker.io/autonomy/kernel:f2a8e95 /boot/vmlinux /vmlinux
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
2019-07-21 21:27:15 +03:00
FROM build AS rootfs-base
2020-02-14 22:33:40 +03:00
COPY --from= docker.io/autonomy/fhs:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/ca-certificates:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/containerd:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/dosfstools:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/eudev:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/iptables:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/libressl:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/libseccomp:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/musl:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/runc:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/socat:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/syslinux:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/xfsprogs:f2a8e95 / /rootfs
COPY --from= docker.io/autonomy/util-linux:f2a8e95 /lib/libblkid.* /rootfs/lib
COPY --from= docker.io/autonomy/util-linux:f2a8e95 /lib/libuuid.* /rootfs/lib
COPY --from= docker.io/autonomy/kmod:f2a8e95 /usr/lib/libkmod.* /rootfs/lib
COPY --from= docker.io/autonomy/kernel:f2a8e95 /lib/modules /rootfs/lib/modules
2019-07-21 21:27:15 +03:00
COPY --from= machined /machined /rootfs/sbin/init
2019-12-24 23:23:52 +03:00
ARG IMAGES
COPY ${ IMAGES } /apid.tar /rootfs/usr/images/
COPY ${ IMAGES } /ntpd.tar /rootfs/usr/images/
COPY ${ IMAGES } /osd.tar /rootfs/usr/images/
COPY ${ IMAGES } /trustd.tar /rootfs/usr/images/
COPY ${ IMAGES } /networkd.tar /rootfs/usr/images/
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
2019-12-05 02:20:17 +03:00
COPY hack/containerd.toml /rootfs/etc/cri/containerd.toml
2019-07-21 21:27:15 +03:00
RUN touch /rootfs/etc/resolv.conf
RUN touch /rootfs/etc/hosts
RUN touch /rootfs/etc/os-release
2019-10-15 05:03:38 +03:00
RUN mkdir -pv /rootfs/{ boot,usr/local/share,mnt}
2019-07-21 21:27:15 +03: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 03:24:51 +03:00
2019-07-21 21:27:15 +03:00
FROM rootfs-base AS rootfs-squashfs
COPY --from= rootfs / /rootfs
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
2019-10-31 01:52:36 +03:00
FROM scratch AS squashfs
COPY --from= rootfs-squashfs /rootfs.sqsh /
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.
FROM build AS initramfs-archive
WORKDIR /initramfs
2019-10-31 01:52:36 +03:00
COPY --from= squashfs /rootfs.sqsh .
2019-07-21 21:27:15 +03: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-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 / /
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
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-19 05:31:43 +03:00
FROM alpine:3.8 AS installer
2019-10-31 01:52:36 +03:00
RUN apk add --no-cache --update \
2019-06-26 05:25:57 +03:00
bash \
2019-09-23 13:42:35 +03:00
ca-certificates \
2019-06-26 05:25:57 +03:00
cdrkit \
qemu-img \
syslinux \
util-linux \
2019-11-04 09:28:10 +03:00
xfsprogs
2019-05-16 02:14:30 +03:00
COPY --from= kernel /vmlinuz /usr/install/vmlinuz
2019-07-21 21:27:15 +03:00
COPY --from= rootfs /usr/lib/syslinux/ /usr/lib/syslinux
2019-05-16 02:14:30 +03:00
COPY --from= initramfs /initramfs.xz /usr/install/initramfs.xz
2019-11-01 07:55:58 +03:00
COPY --from= installer-build /installer /bin/installer
RUN ln -s /bin/installer /bin/osctl
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 } "
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
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 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-13 03:24:51 +03: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 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
2019-08-09 06:45:13 +03: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-05 00:19:34 +03: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-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
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
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
2019-07-13 03:24:51 +03:00
COPY hack/golang/golangci-lint.yaml .
2019-09-12 00:58:51 +03:00
ENV GOGC = 50
2019-07-26 20:21:45 +03:00
RUN --mount= type = cache,target= /.cache/go-build golangci-lint run --config golangci-lint.yaml
2019-09-10 21:12:28 +03:00
RUN find . -name '*.pb.go' | xargs rm
2019-09-12 17:32:42 +03: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 11:51:40 +03:00
2019-08-28 00:45:59 +03:00
# The protolint target performs linting on Markdown files.
2019-12-24 20:28:58 +03:00
FROM base AS lint-protobuf
2019-08-28 00:45:59 +03:00
COPY prototool.yaml /src
RUN prototool lint --protoc-bin-path= /toolchain/bin/protoc --protoc-wkt-path= /toolchain/include .
2019-08-17 11:51:40 +03:00
# The markdownlint target performs linting on Markdown files.
2019-12-24 20:28:58 +03:00
FROM node:8.16.1-alpine AS lint-markdown
2019-08-17 11:51:40 +03:00
RUN npm install -g markdownlint-cli
2019-08-17 19:55:48 +03:00
RUN npm i sentences-per-line
2019-08-17 11:51:40 +03:00
WORKDIR /src
COPY .markdownlint.json .
COPY docs .
2019-08-17 19:55:48 +03:00
RUN markdownlint --rules /node_modules/sentences-per-line/index.js .
2019-12-24 23:23:52 +03:00
# The docs target generates documentation.
FROM base AS docs-build
RUN go generate ./pkg/config/types/v1alpha1
COPY --from= osctl-linux /osctl-linux-amd64 /bin/osctl
RUN mkdir -p /docs/osctl \
&& env HOME = /home/user TAG = latest /bin/osctl docs /docs/osctl
FROM scratch AS docs
COPY --from= docs-build /tmp/v1alpha1.md /docs/website/content/v0.3/en/configuration/v1alpha1.md
COPY --from= docs-build /docs/osctl/* /docs/osctl/