From fe36c4924628467a971368b3b693a7fef4c0c415 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Wed, 20 May 2020 14:32:56 +0200 Subject: [PATCH] Use alpine as base image Installing docker on buster is a pain, use alpine to install it --- Dockerfile | 9 +++++---- backend/v1/backend.pb.go | 2 +- builder.Makefile | 4 ++-- cli/cmd/context/testdata/ls-out.golden | 6 +++--- cli/cmd/ps_test.go | 4 ++-- cli/v1/cli.pb.go | 2 +- compose/v1/compose.pb.go | 2 +- containers/v1/containers.pb.go | 2 +- context/store/store.go | 2 ++ 9 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3f7f2eb4..257cf673 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax = docker/dockerfile:experimental -ARG GO_VERSION=1.14.2 +ARG GO_VERSION=1.14.3-alpine3.11 FROM golang:${GO_VERSION} AS base ARG TARGET_OS=unknown @@ -7,6 +7,8 @@ ARG TARGET_ARCH=unknown ARG PWD=/api ENV GO111MODULE=on +RUN apk update && apk add docker make + WORKDIR ${PWD} ADD go.* ${PWD} RUN go mod download @@ -18,9 +20,7 @@ ARG TARGET_ARCH=unknown ARG PWD=/api ENV GO111MODULE=on -RUN apt-get update && apt-get install --no-install-recommends -y \ - protobuf-compiler \ - libprotobuf-dev +RUN apk update && apk add protoc make RUN go get github.com/golang/protobuf/protoc-gen-go@v1.4.1 && \ go get golang.org/x/tools/cmd/goimports @@ -52,4 +52,5 @@ FROM scratch AS cross COPY --from=make-cross /api/bin/* . FROM base as test +ENV CGO_ENABLED=0 RUN make -f builder.Makefile test diff --git a/backend/v1/backend.pb.go b/backend/v1/backend.pb.go index b93e99e7..457e7ed6 100644 --- a/backend/v1/backend.pb.go +++ b/backend/v1/backend.pb.go @@ -27,7 +27,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.22.0 -// protoc v3.6.1 +// protoc v3.11.2 // source: backend/v1/backend.proto package v1 diff --git a/builder.Makefile b/builder.Makefile index 4b2cff49..763106cc 100644 --- a/builder.Makefile +++ b/builder.Makefile @@ -26,14 +26,14 @@ GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) -PROTOS=$(shell find . -name \*.proto) +PROTOS=$(shell find . -not \( -path ./tests -prune \) -name \*.proto) EXTENSION := ifeq ($(GOOS),windows) EXTENSION := .exe endif -STATIC_FLAGS= CGO_ENABLED=0 +STATIC_FLAGS=CGO_ENABLED=0 LDFLAGS := "-s -w" GO_BUILD = $(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS) diff --git a/cli/cmd/context/testdata/ls-out.golden b/cli/cmd/context/testdata/ls-out.golden index 44d5702a..c4b2668e 100644 --- a/cli/cmd/context/testdata/ls-out.golden +++ b/cli/cmd/context/testdata/ls-out.golden @@ -1,3 +1,3 @@ -NAME TYPE DESCRIPTION DOCKER ENPOINT KUBERNETES ENDPOINT ORCHESTRATOR -default docker Current DOCKER_HOST based configuration unix:///var/run/docker.sock https://35.205.93.167 (default) swarm -example * example +NAME TYPE DESCRIPTION DOCKER ENPOINT KUBERNETES ENDPOINT ORCHESTRATOR +default docker Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm +example * example diff --git a/cli/cmd/ps_test.go b/cli/cmd/ps_test.go index 8011f6f2..ed90bfa9 100644 --- a/cli/cmd/ps_test.go +++ b/cli/cmd/ps_test.go @@ -75,7 +75,7 @@ func (sut *PsSuite) TestPs() { } err := runPs(sut.ctx, opts) - assert.NilError(sut.T(), err) + assert.Nil(sut.T(), err) golden.Assert(sut.T(), sut.getStdOut(), "ps-out.golden") } @@ -86,7 +86,7 @@ func (sut *PsSuite) TestPsQuiet() { } err := runPs(sut.ctx, opts) - assert.NilError(sut.T(), err) + assert.Nil(sut.T(), err) golden.Assert(sut.T(), sut.getStdOut(), "ps-out-quiet.golden") } diff --git a/cli/v1/cli.pb.go b/cli/v1/cli.pb.go index 8a8be691..768d0b63 100644 --- a/cli/v1/cli.pb.go +++ b/cli/v1/cli.pb.go @@ -27,7 +27,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.22.0 -// protoc v3.6.1 +// protoc v3.11.2 // source: cli/v1/cli.proto package v1 diff --git a/compose/v1/compose.pb.go b/compose/v1/compose.pb.go index f0dda24c..dd41b876 100644 --- a/compose/v1/compose.pb.go +++ b/compose/v1/compose.pb.go @@ -27,7 +27,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.22.0 -// protoc v3.6.1 +// protoc v3.11.2 // source: compose/v1/compose.proto package v1 diff --git a/containers/v1/containers.pb.go b/containers/v1/containers.pb.go index d7846628..b71a9507 100644 --- a/containers/v1/containers.pb.go +++ b/containers/v1/containers.pb.go @@ -27,7 +27,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.22.0 -// protoc v3.6.1 +// protoc v3.11.2 // source: containers/v1/containers.proto package v1 diff --git a/context/store/store.go b/context/store/store.go index d31bd044..441419f2 100644 --- a/context/store/store.go +++ b/context/store/store.go @@ -264,6 +264,8 @@ func (s *store) List() ([]*Metadata, error) { } } + // The default context is not stored in the store, it is in-memory only + // so we need a special case for it. dockerDefault, err := dockerGefaultContext() if err != nil { return nil, err