Skip to content

Commit

Permalink
Optimize docker images build time
Browse files Browse the repository at this point in the history
  • Loading branch information
palexster committed May 19, 2021
1 parent 251d714 commit 2cbef45
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- 'v*'
branches:
- master
pull_request_target:
pull_request:
types:
- opened
- reopened
Expand All @@ -30,7 +30,7 @@ jobs:
id: configure
run: |
# The ref of the commit to checkout (do not use the merge commit if pull request)
if [ "${{ github.event_name }}" == "pull_request_target" ]; then
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "::set-output name=master::false"
echo "::set-output name=architectures::linux/amd64"
echo "::set-output name=commit_ref::${{ github.event.pull_request.head.sha }}"
Expand All @@ -49,7 +49,7 @@ jobs:
echo "::set-output name=repo-suffix::-ci" ||
echo "::set-output name=repo-suffix::"
if [ "${{ github.event_name }}" != "pull_request_target" ]; then
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "::set-output name=ok-to-continue::true"
echo "::set-output name=repo-name::${{ github.repository }}"
elif [ "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]; then
Expand Down
3 changes: 3 additions & 0 deletions build/advertisement-broadcaster/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/advertisement-broadcaster/
Expand Down
3 changes: 3 additions & 0 deletions build/advertisement-operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/advertisement-operator/
Expand Down
3 changes: 3 additions & 0 deletions build/auth-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/auth-service/
Expand Down
3 changes: 3 additions & 0 deletions build/crd-replicator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/crd-replicator/
Expand Down
3 changes: 3 additions & 0 deletions build/discovery/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/discovery/
Expand Down
3 changes: 3 additions & 0 deletions build/init-virtual-kubelet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ FROM golang:1.16 as builder

ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
ARG BUILD_TAGS=""
Expand Down
4 changes: 4 additions & 0 deletions build/liqo-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:/usr/local/kubebuilder/bin:$PATH
ENV GOPATH /go

COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download

# Install kubebuilder
RUN curl -sL https://go.kubebuilder.io/dl/2.3.0/$(go env GOOS)/$(go env GOARCH) | tar -xz -C /tmp/
RUN mv /tmp/kubebuilder_2.3.0_$(go env GOOS)_$(go env GOARCH) /usr/local/kubebuilder
Expand Down
3 changes: 3 additions & 0 deletions build/liqo-webhook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/liqo-webhook/
Expand Down
3 changes: 3 additions & 0 deletions build/liqonet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ RUN cargo build --bin boringtun --release
FROM golang:1.16-alpine AS goBuilder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
RUN apk update && apk add git make
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
Expand Down
4 changes: 3 additions & 1 deletion build/uninstaller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo

ARG BUILD_TAGS=""
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/uninstaller/
RUN cp uninstaller /usr/bin/uninstaller
Expand Down
5 changes: 3 additions & 2 deletions build/virtual-kubelet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM golang:1.16 as builder

ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo

ARG BUILD_TAGS=""
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/virtual-kubelet/
RUN cp virtual-kubelet /usr/bin/virtual-kubelet
Expand Down
3 changes: 3 additions & 0 deletions build/webhook-configuration/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM golang:1.16 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY go.mod /go/src/github.com/liqotech/liqo/go.mod
COPY go.sum /go/src/github.com/liqotech/liqo/go.sum
RUN cd /go/src/github.com/liqotech/liqo/ && go mod download
COPY . /go/src/github.com/liqotech/liqo
WORKDIR /go/src/github.com/liqotech/liqo
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$(go env GOARCH) go build ./cmd/webhook-configuration/
Expand Down

0 comments on commit 2cbef45

Please sign in to comment.