Skip to content

Commit 20c5a8c

Browse files
committed
update build system
Signed-off-by: Markus Blaschke <mblaschke82@gmail.com>
1 parent d314c27 commit 20c5a8c

File tree

7 files changed

+150
-71
lines changed

7 files changed

+150
-71
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# top-most EditorConfig file
44
root = true
5-
charset = utf-8
6-
trim_trailing_whitespace = true
75

86
[*]
7+
charset = utf-8
8+
trim_trailing_whitespace = true
99
end_of_line = lf
1010
insert_final_newline = true
1111
indent_style = space

.github/workflows/ci-docker.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ name: "CI: docker build"
33
on: [pull_request]
44

55
jobs:
6-
76
build:
8-
97
runs-on: ubuntu-latest
10-
118
steps:
12-
- uses: actions/checkout@v2
13-
- name: Build the Docker image
14-
run: docker build . --file Dockerfile --tag webdevops/kube-bootstrap-token-manager:$(date +%s)
9+
- uses: actions/checkout@v2
10+
11+
- name: Run Gosec Security Scanner
12+
uses: securego/gosec@master
13+
with:
14+
args: ./...
15+
16+
- name: Run Golangci lint
17+
uses: golangci/golangci-lint-action@v2
18+
with:
19+
version: latest
20+
args: -E exportloopref,gofmt --timeout=30m
21+
22+
- name: Build the Docker image
23+
run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s)
Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: "Release: docker"
22

33
on:
4-
schedule:
5-
- cron: '0 6 * * 1'
64
push:
75
branches:
86
- '**'
@@ -13,39 +11,52 @@ jobs:
1311
build:
1412
runs-on: ubuntu-latest
1513
steps:
16-
- uses: actions/checkout@v2
17-
- name: Docker meta
18-
id: docker_meta
19-
uses: crazy-max/ghaction-docker-meta@v1
20-
with:
21-
images: webdevops/kube-bootstrap-token-manager,quay.io/webdevops/kube-bootstrap-token-manager
22-
#tag-sha: true
23-
24-
- name: Set up QEMU
25-
uses: docker/setup-qemu-action@v1
26-
27-
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v1
29-
30-
- name: Login to DockerHub
31-
uses: docker/login-action@v1
32-
with:
33-
username: ${{ secrets.DOCKERHUB_USERNAME }}
34-
password: ${{ secrets.DOCKERHUB_TOKEN }}
35-
36-
- name: Login to Quay
37-
uses: docker/login-action@v1
38-
with:
39-
registry: quay.io
40-
username: ${{ secrets.QUAY_USERNAME }}
41-
password: ${{ secrets.QUAY_TOKEN }}
42-
43-
- name: Build and push
44-
uses: docker/build-push-action@v2
45-
with:
46-
context: .
47-
file: ./Dockerfile
48-
platforms: linux/amd64,linux/arm,linux/arm64,linux/ppc64le
49-
push: ${{ github.event_name != 'pull_request' }}
50-
tags: ${{ steps.docker_meta.outputs.tags }}
51-
labels: ${{ steps.docker_meta.outputs.labels }}
14+
- uses: actions/checkout@v2
15+
16+
- name: Run Gosec Security Scanner
17+
uses: securego/gosec@master
18+
with:
19+
args: ./...
20+
21+
- name: Run Golangci lint
22+
uses: golangci/golangci-lint-action@v2
23+
with:
24+
version: latest
25+
args: -E exportloopref,gofmt --timeout=30m
26+
27+
- name: Docker meta
28+
id: docker_meta
29+
uses: docker/metadata-action@v3
30+
with:
31+
images: ${{ github.repository }},quay.io/${{ github.repository }}
32+
labels: |
33+
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v1
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v1
40+
41+
- name: Login to DockerHub
42+
uses: docker/login-action@v1
43+
with:
44+
username: ${{ secrets.DOCKERHUB_USERNAME }}
45+
password: ${{ secrets.DOCKERHUB_TOKEN }}
46+
47+
- name: Login to Quay
48+
uses: docker/login-action@v1
49+
with:
50+
registry: quay.io
51+
username: ${{ secrets.QUAY_USERNAME }}
52+
password: ${{ secrets.QUAY_TOKEN }}
53+
54+
- name: Build and push
55+
uses: docker/build-push-action@v2
56+
with:
57+
context: .
58+
file: ./Dockerfile
59+
platforms: linux/amd64,linux/arm,linux/arm64,linux/ppc64le
60+
push: ${{ github.event_name != 'pull_request' }}
61+
tags: ${{ steps.docker_meta.outputs.tags }}
62+
labels: ${{ steps.docker_meta.outputs.labels }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "Scheduled: docker"
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * 1'
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Run Gosec Security Scanner
14+
uses: securego/gosec@master
15+
with:
16+
args: ./...
17+
18+
- name: Run Golangci lint
19+
uses: golangci/golangci-lint-action@v2
20+
with:
21+
version: latest
22+
args: -E exportloopref,gofmt --timeout=30m
23+
24+
- name: Docker meta
25+
id: docker_meta
26+
uses: docker/metadata-action@v3
27+
with:
28+
images: ${{ github.repository }},quay.io/${{ github.repository }}
29+
labels: |
30+
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md
31+
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v1
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v1
37+
38+
- name: Login to DockerHub
39+
uses: docker/login-action@v1
40+
with:
41+
username: ${{ secrets.DOCKERHUB_USERNAME }}
42+
password: ${{ secrets.DOCKERHUB_TOKEN }}
43+
44+
- name: Login to Quay
45+
uses: docker/login-action@v1
46+
with:
47+
registry: quay.io
48+
username: ${{ secrets.QUAY_USERNAME }}
49+
password: ${{ secrets.QUAY_TOKEN }}
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v2
53+
with:
54+
context: .
55+
file: ./Dockerfile
56+
platforms: linux/amd64,linux/arm,linux/arm64,linux/ppc64le
57+
push: ${{ github.event_name != 'pull_request' }}
58+
tags: ${{ steps.docker_meta.outputs.tags }}
59+
labels: ${{ steps.docker_meta.outputs.labels }}

Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
FROM golang:1.15 as build
1+
FROM golang:1.17-alpine as build
22

3-
WORKDIR /go/src/github.com/webdevops/kube-bootstrap-token-manager
4-
5-
# Get deps (cached)
6-
COPY ./go.mod /go/src/github.com/webdevops/kube-bootstrap-token-manager
7-
COPY ./go.sum /go/src/github.com/webdevops/kube-bootstrap-token-manager
8-
COPY ./Makefile /go/src/github.com/webdevops/kube-bootstrap-token-manager
9-
RUN make dependencies
3+
RUN apk upgrade --no-cache --force
4+
RUN apk add --update build-base make git
105

6+
WORKDIR /go/src/github.com/webdevops/kube-bootstrap-token-manager
117
# Compile
128
COPY ./ /go/src/github.com/webdevops/kube-bootstrap-token-manager
9+
RUN make dependencies
1310
RUN make test
14-
RUN make lint
1511
RUN make build
1612
RUN ./kube-bootstrap-token-manager --help
1713

1814
#############################################
1915
# FINAL IMAGE
2016
#############################################
21-
FROM gcr.io/distroless/base
17+
FROM gcr.io/distroless/static
2218
ENV LOG_JSON=1
2319
COPY --from=build /go/src/github.com/webdevops/kube-bootstrap-token-manager/kube-bootstrap-token-manager /
24-
USER 1000
20+
USER 1000:1000
2521
ENTRYPOINT ["/kube-bootstrap-token-manager"]

Makefile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PROJECT_NAME := kube-bootstrap-token-manager
22
GIT_TAG := $(shell git describe --dirty --tags --always)
33
GIT_COMMIT := $(shell git rev-parse --short HEAD)
4-
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -extldflags "-static"
4+
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -linkmode external -extldflags "-static" -s -w
55

66
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH)))
77
GOLANGCI_LINT_BIN := $(FIRST_GOPATH)/bin/golangci-lint
@@ -34,12 +34,20 @@ build-push-development:
3434
test:
3535
go test ./...
3636

37+
.PHONY: dependencies
38+
dependencies:
39+
go mod vendor
40+
3741
.PHONY: lint
3842
lint: $(GOLANGCI_LINT_BIN)
39-
$(GOLANGCI_LINT_BIN) run -E exportloopref,gofmt --timeout=10m
43+
$(GOLANGCI_LINT_BIN) run -E exportloopref,gofmt --timeout=30m
4044

41-
.PHONY: dependencies
42-
dependencies: $(GOLANGCI_LINT_BIN)
45+
.PHONY: gosec
46+
gosec: $(GOSEC_BIN)
47+
$(GOSEC_BIN) ./...
4348

4449
$(GOLANGCI_LINT_BIN):
45-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin v1.32.2
50+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
51+
52+
$(GOSEC_BIN):
53+
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(FIRST_GOPATH)/bin v2.7.0

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Kubernetes node bootstrap token manager
2-
========================================
1+
# Kubernetes node bootstrap token manager
32

43
[![license](https://img.shields.io/github/license/webdevops/kube-bootstrap-token-manager.svg)](https://github.com/webdevops/kube-bootstrap-token-manager/blob/master/LICENSE)
54
[![DockerHub](https://img.shields.io/badge/DockerHub-webdevops%2Fkube--bootstrap--token--manager-blue)](https://hub.docker.com/r/webdevops/kube-bootstrap-token-manager/)
@@ -14,8 +13,7 @@ Azure:
1413
- (re)creates token inside Kubernetes and ensures it existence
1514
- Manages renewal if token is going to be expired
1615

17-
Configuration
18-
-------------
16+
## Configuration
1917

2018
```
2119
Usage:
@@ -52,10 +50,9 @@ Help Options:
5250
-h, --help Show this help message
5351
```
5452

55-
for Azure API authentication (using ENV vars) see https://github.com/Azure/azure-sdk-for-go#authentication
53+
for Azure API authentication (using ENV vars) see https://docs.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication
5654

57-
Metrics
58-
-------
55+
## Metrics
5956

6057
(see `:8080/metrics`)
6158

@@ -67,7 +64,6 @@ Metrics
6764
| `bootstraptoken_sync_time` | Timestamp of last sync |
6865
| `bootstraptoken_sync_count` | Counter of sync |
6966

70-
Kubernetes deployment
71-
---------------------
67+
## Kubernetes deployment
7268

7369
see [deployment](/deployment)

0 commit comments

Comments
 (0)