From aaade8676c946db91b42388ce22f0312807d9ac0 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:20:41 -0500 Subject: [PATCH 01/22] Update Dockerfile use golang as builder, update linker flags --- Dockerfile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d915775..e1b340c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,19 @@ #first stage - builder -FROM gravitl/builder as builder - +FROM golang:1.15 as builder +ARG version WORKDIR /app - COPY . . - ENV GO111MODULE=auto - -RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go build -ldflags="-w -s" -o netmaker main.go +RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version" -o netmaker main.go FROM alpine:3.13.6 # add a c lib RUN apk add gcompat iptables # set the working directory WORKDIR /root/ - RUN mkdir -p /etc/netclient/config - COPY --from=builder /app/netmaker . COPY --from=builder /app/config config - EXPOSE 8081 EXPOSE 50051 - ENTRYPOINT ["./netmaker"] From 44478f4e58f500a7cd6a0c4125cd930ab82c0065 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:22:44 -0500 Subject: [PATCH 02/22] Update publish-docker.yml use generic repo --- .github/workflows/publish-docker.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 48611e48..647df044 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -6,10 +6,8 @@ on: tag: description: 'docker tag' required: true - pull_request: - branches: - - 'test' - - 'master' + release: + types: [published] jobs: docker: @@ -31,8 +29,7 @@ jobs: uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - if: github.event_name != 'pull_request' - name: Login to DockerHub + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -42,5 +39,5 @@ jobs: with: context: . platforms: linux/amd64, linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: gravitl/netmaker:${{ env.TAG }} + push: true + tags: ${{ github.respository }}:${{ env.TAG }} From 4d1570c04a78acf5d54e0dcc34739697e8803d8b Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:37:34 -0500 Subject: [PATCH 03/22] tweak workflow --- .github/workflows/publish-docker.yml | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 647df044..8f8f4841 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -13,7 +13,8 @@ jobs: docker: runs-on: ubuntu-latest steps: - - name: Set tag + - + name: Set tag run: | if [[ -n "${{ github.event.inputs.tag }}" ]]; then TAG=${{ github.event.inputs.tag }} @@ -23,18 +24,34 @@ jobs: TAG="${{ github.base_ref }}" fi echo "TAG=${TAG}" >> $GITHUB_ENV - - name: Checkout + - + name: Checkout uses: actions/checkout@v2 - - name: Set up QEMU + - + name: Set up QEMU uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx + - + name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub + - + name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push latest + - + name: Build and export to Docker + uses: docker/build-push-action@v2 + with: + context: . + load: true + tags: ${{ env.TEST_TAG }} + - + name: Test + run: | + docker run --rm ${{ env.TEST_TAG }} + - + name: Build and push uses: docker/build-push-action@v2 with: context: . From 0aa11e085bc8e7d62c0ddeb41f140d887927e221 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:50:44 -0500 Subject: [PATCH 04/22] missing quote --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e1b340c9..48fc58f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG version WORKDIR /app COPY . . ENV GO111MODULE=auto -RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version" -o netmaker main.go +RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version'" -o netmaker main.go FROM alpine:3.13.6 # add a c lib From f866be5d64f60e1b8c72796f30eea76044b1a17e Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:54:43 -0500 Subject: [PATCH 05/22] tweak workflow --- .github/workflows/publish-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 8f8f4841..5ee61279 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -45,11 +45,11 @@ jobs: with: context: . load: true - tags: ${{ env.TEST_TAG }} + tags: ${{ env.TAG }} - name: Test run: | - docker run --rm ${{ env.TEST_TAG }} + docker run --rm ${{ env.TAG }} - name: Build and push uses: docker/build-push-action@v2 From cd8b932b6e5ae3aead90da37609a1ea3a4ece2a0 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:32:21 +0000 Subject: [PATCH 06/22] use golang-alpine as builder and add package to permit finding of gcc --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 48fc58f6..da9d8b5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ #first stage - builder -FROM golang:1.15 as builder +FROM golang:1.15-alpine as builder ARG version +RUN apk add build-base WORKDIR /app COPY . . ENV GO111MODULE=auto From 7e8fd2e26e642491e43c3e0448a419d92e8bd4e4 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:49:34 +0000 Subject: [PATCH 07/22] refine test of docker image --- .github/workflows/publish-docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 5ee61279..b3225cf8 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -45,11 +45,12 @@ jobs: with: context: . load: true + platforms: linux/amd64,linux/arm64 tags: ${{ env.TAG }} - name: Test run: | - docker run --rm ${{ env.TAG }} + docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} - name: Build and push uses: docker/build-push-action@v2 From 12c166c3bb2c56698fc0711e48856a0fdc31078f Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:55:51 +0000 Subject: [PATCH 08/22] split test by arch --- .github/workflows/publish-docker.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index b3225cf8..024328bd 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -40,15 +40,27 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and export to Docker + name: Build x86 and export to Docker uses: docker/build-push-action@v2 with: context: . load: true - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 tags: ${{ env.TAG }} - - name: Test + name: Test x86 + run: | + docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} + - + name: Build arm and export to Docker + uses: docker/build-push-action@v2 + with: + context: . + load: true + platforms: linux/arm64 + tags: ${{ env.TAG }} + - + name: Test arm run: | docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} - From 7f55e970c99f6598a7a0971503c7e63b12843f7c Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 19:22:59 +0000 Subject: [PATCH 09/22] refine test --- .github/workflows/publish-docker.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 024328bd..c8582d5c 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -50,7 +50,9 @@ jobs: - name: Test x86 run: | - docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} + docker run --rm ${{ env.TAG }} + sleep 10 + kill %1 - name: Build arm and export to Docker uses: docker/build-push-action@v2 @@ -62,7 +64,9 @@ jobs: - name: Test arm run: | - docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} + docker run --rm ${{ env.TAG }} + sleep 10 + kill %1 - name: Build and push uses: docker/build-push-action@v2 From a378b8a7844ab6cee7b3cc1660ae96c1dd462ed8 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 19:25:31 +0000 Subject: [PATCH 10/22] refine test again --- .github/workflows/publish-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index c8582d5c..c09b15b7 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -50,7 +50,7 @@ jobs: - name: Test x86 run: | - docker run --rm ${{ env.TAG }} + docker run --rm ${{ env.TAG }}& sleep 10 kill %1 - @@ -64,7 +64,7 @@ jobs: - name: Test arm run: | - docker run --rm ${{ env.TAG }} + docker run --rm ${{ env.TAG }}& sleep 10 kill %1 - From 2f40490c26839ab6c531ef60993712d2587eea99 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 20:30:30 +0000 Subject: [PATCH 11/22] spelling --- .github/workflows/publish-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index c09b15b7..91aae3f2 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -74,4 +74,4 @@ jobs: context: . platforms: linux/amd64, linux/arm64 push: true - tags: ${{ github.respository }}:${{ env.TAG }} + tags: ${{ github.repository }}:${{ env.TAG }} From 3378c3cf1fd928101802d5ea33a2d17f0f08ff7d Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:20:41 -0500 Subject: [PATCH 12/22] Update Dockerfile use golang as builder, update linker flags --- Dockerfile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d915775..e1b340c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,19 @@ #first stage - builder -FROM gravitl/builder as builder - +FROM golang:1.15 as builder +ARG version WORKDIR /app - COPY . . - ENV GO111MODULE=auto - -RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go build -ldflags="-w -s" -o netmaker main.go +RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version" -o netmaker main.go FROM alpine:3.13.6 # add a c lib RUN apk add gcompat iptables # set the working directory WORKDIR /root/ - RUN mkdir -p /etc/netclient/config - COPY --from=builder /app/netmaker . COPY --from=builder /app/config config - EXPOSE 8081 EXPOSE 50051 - ENTRYPOINT ["./netmaker"] From 4e48e1d0fd5e95f07a50fd89aace6de079c2c8c9 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:22:44 -0500 Subject: [PATCH 13/22] Update publish-docker.yml use generic repo --- .github/workflows/publish-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 427a2a87..647df044 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -40,4 +40,4 @@ jobs: context: . platforms: linux/amd64, linux/arm64 push: true - tags: gravitl/netmaker:${{ env.TAG }} + tags: ${{ github.respository }}:${{ env.TAG }} From bfb3bcd4ae35e970ad433174f6b1982c404c98ff Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:37:34 -0500 Subject: [PATCH 14/22] tweak workflow --- .github/workflows/publish-docker.yml | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 647df044..8f8f4841 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -13,7 +13,8 @@ jobs: docker: runs-on: ubuntu-latest steps: - - name: Set tag + - + name: Set tag run: | if [[ -n "${{ github.event.inputs.tag }}" ]]; then TAG=${{ github.event.inputs.tag }} @@ -23,18 +24,34 @@ jobs: TAG="${{ github.base_ref }}" fi echo "TAG=${TAG}" >> $GITHUB_ENV - - name: Checkout + - + name: Checkout uses: actions/checkout@v2 - - name: Set up QEMU + - + name: Set up QEMU uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx + - + name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub + - + name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push latest + - + name: Build and export to Docker + uses: docker/build-push-action@v2 + with: + context: . + load: true + tags: ${{ env.TEST_TAG }} + - + name: Test + run: | + docker run --rm ${{ env.TEST_TAG }} + - + name: Build and push uses: docker/build-push-action@v2 with: context: . From 0bc39f10d81e3663c81b079fbafc0015bfab543f Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:50:44 -0500 Subject: [PATCH 15/22] missing quote --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e1b340c9..48fc58f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG version WORKDIR /app COPY . . ENV GO111MODULE=auto -RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version" -o netmaker main.go +RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version'" -o netmaker main.go FROM alpine:3.13.6 # add a c lib From f50410acf511223553211f1445d99b14cdd6b2b9 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 10:54:43 -0500 Subject: [PATCH 16/22] tweak workflow --- .github/workflows/publish-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 8f8f4841..5ee61279 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -45,11 +45,11 @@ jobs: with: context: . load: true - tags: ${{ env.TEST_TAG }} + tags: ${{ env.TAG }} - name: Test run: | - docker run --rm ${{ env.TEST_TAG }} + docker run --rm ${{ env.TAG }} - name: Build and push uses: docker/build-push-action@v2 From 8b04b77dcca8e2f13f332088b6e7d7a6a3f34c1a Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:32:21 +0000 Subject: [PATCH 17/22] use golang-alpine as builder and add package to permit finding of gcc --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 48fc58f6..da9d8b5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ #first stage - builder -FROM golang:1.15 as builder +FROM golang:1.15-alpine as builder ARG version +RUN apk add build-base WORKDIR /app COPY . . ENV GO111MODULE=auto From 239508582deec4a0727be18f23c8c6d5d2e34ada Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:49:34 +0000 Subject: [PATCH 18/22] refine test of docker image --- .github/workflows/publish-docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 5ee61279..b3225cf8 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -45,11 +45,12 @@ jobs: with: context: . load: true + platforms: linux/amd64,linux/arm64 tags: ${{ env.TAG }} - name: Test run: | - docker run --rm ${{ env.TAG }} + docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} - name: Build and push uses: docker/build-push-action@v2 From 60d60a276d44f29e98e595ad8eec91e51234fecb Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:55:51 +0000 Subject: [PATCH 19/22] split test by arch --- .github/workflows/publish-docker.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index b3225cf8..024328bd 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -40,15 +40,27 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and export to Docker + name: Build x86 and export to Docker uses: docker/build-push-action@v2 with: context: . load: true - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 tags: ${{ env.TAG }} - - name: Test + name: Test x86 + run: | + docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} + - + name: Build arm and export to Docker + uses: docker/build-push-action@v2 + with: + context: . + load: true + platforms: linux/arm64 + tags: ${{ env.TAG }} + - + name: Test arm run: | docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} - From 29600f5024c12c67105489449907a5967f9869e1 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 19:22:59 +0000 Subject: [PATCH 20/22] refine test --- .github/workflows/publish-docker.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 024328bd..c8582d5c 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -50,7 +50,9 @@ jobs: - name: Test x86 run: | - docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} + docker run --rm ${{ env.TAG }} + sleep 10 + kill %1 - name: Build arm and export to Docker uses: docker/build-push-action@v2 @@ -62,7 +64,9 @@ jobs: - name: Test arm run: | - docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }} + docker run --rm ${{ env.TAG }} + sleep 10 + kill %1 - name: Build and push uses: docker/build-push-action@v2 From 334a3de57ebd577b7b427706629b185e57acd630 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 19:25:31 +0000 Subject: [PATCH 21/22] refine test again --- .github/workflows/publish-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index c8582d5c..c09b15b7 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -50,7 +50,7 @@ jobs: - name: Test x86 run: | - docker run --rm ${{ env.TAG }} + docker run --rm ${{ env.TAG }}& sleep 10 kill %1 - @@ -64,7 +64,7 @@ jobs: - name: Test arm run: | - docker run --rm ${{ env.TAG }} + docker run --rm ${{ env.TAG }}& sleep 10 kill %1 - From fc51a76466341ed0560cc245d1c69547b5e79d08 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 20:30:30 +0000 Subject: [PATCH 22/22] spelling --- .github/workflows/publish-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index c09b15b7..91aae3f2 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -74,4 +74,4 @@ jobs: context: . platforms: linux/amd64, linux/arm64 push: true - tags: ${{ github.respository }}:${{ env.TAG }} + tags: ${{ github.repository }}:${{ env.TAG }}