Skip to content

Commit

Permalink
cleanup docker build (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejtomcik authored Apr 7, 2020
1 parent 6c63f90 commit 98d6121
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 25 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM golang:1.13.5-alpine3.10 AS cloud-build
FROM golang:1.13.5-alpine3.10 AS test-build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY . .
RUN go mod download
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ SHELL = /bin/bash
SIMULATOR_NAME_SUFFIX ?= $(shell hostname)

SUBDIRS := resource-aggregate authorization resource-directory openapi-connector openapi-gateway coap-gateway grpc-gateway certificate-authority portal-webapi bundle
.PHONY: $(SUBDIRS) push proto/generate clean build test env make-mongo make-nats make-ca cloud-build
.PHONY: $(SUBDIRS) push proto/generate clean build test env make-mongo make-nats make-ca test-build

default: build

cloud-build:
docker build \
--network=host \
--tag cloud-build \
.

make-ca:
docker pull ocfcloud/step-ca:vnext
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then \
Expand Down Expand Up @@ -59,7 +53,13 @@ env: clean make-ca make-nats make-mongo
docker build ./device-simulator --network=host -t device-simulator --target service
docker run -d --name=devsim --network=host -t device-simulator devsim-$(SIMULATOR_NAME_SUFFIX)

test: env cloud-build
test-build:
docker build \
--network=host \
--tag test-build \
.

test: env test-build
docker run \
--network=host \
-v $(shell pwd)/.tmp/step-ca/data/certs/root_ca.crt:/root_ca.crt \
Expand All @@ -72,10 +72,10 @@ test: env cloud-build
-e LISTEN_ACME_DIRECTORY_URL="https://localhost:10443/acme/acme/directory" \
-e TEST_COAP_GW_OVERWRITE_LISTEN_ACME_DIRECTORY_URL="https://localhost:10443/acme/ocf.gw/directory" \
--mount type=bind,source="$(shell pwd)",target=/shared \
cloud-build \
test-build \
go test -p 1 -v ./... -covermode=atomic -coverprofile=/shared/coverage.txt

build: cloud-build $(SUBDIRS)
build: $(SUBDIRS)

clean:
docker rm -f step-ca-test || true
Expand Down
5 changes: 4 additions & 1 deletion authorization/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/authorization
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions authorization/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
7 changes: 6 additions & 1 deletion bundle/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud
COPY . .
RUN go mod download

ARG root_directory=$GOPATH/src/github.com/go-ocf/cloud

#coap-gateway
Expand Down
1 change: 1 addition & 0 deletions bundle/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
5 changes: 4 additions & 1 deletion certificate-authority/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/certificate-authority
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions certificate-authority/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
5 changes: 4 additions & 1 deletion coap-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/coap-gateway
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions coap-gateway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
5 changes: 4 additions & 1 deletion grpc-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/grpc-gateway
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions grpc-gateway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
5 changes: 4 additions & 1 deletion openapi-connector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/openapi-connector
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions openapi-connector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
5 changes: 4 additions & 1 deletion openapi-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/openapi-gateway
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions openapi-gateway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
5 changes: 4 additions & 1 deletion portal-webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/portal-webapi
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions portal-webapi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down
5 changes: 4 additions & 1 deletion resource-aggregate/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/resource-aggregate
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
3 changes: 2 additions & 1 deletion resource-aggregate/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
.
--file Dockerfile \
..
endef

build-servicecontainer:
Expand Down
5 changes: 4 additions & 1 deletion resource-directory/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM cloud-build AS build
FROM golang:1.13.5-alpine3.10 AS build
RUN apk add --no-cache curl git build-base
WORKDIR $GOPATH/src/github.com/go-ocf/cloud/resource-directory
COPY . .
RUN go mod download
RUN go build -o /go/bin/service ./cmd/service

FROM alpine:3.11 as service
Expand Down
1 change: 1 addition & 0 deletions resource-directory/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define build-docker-image
--tag ocfcloud/$(SERVICE_NAME):$(VERSION_TAG) \
--tag ocfcloud/$(SERVICE_NAME):$(LATEST_TAG) \
--target $(1) \
--file Dockerfile \
.
endef

Expand Down

0 comments on commit 98d6121

Please sign in to comment.