From 844eb359595a4af64bb0cba55463f4181864cb68 Mon Sep 17 00:00:00 2001 From: wawlian Date: Thu, 13 Apr 2023 16:28:47 +0800 Subject: [PATCH 1/2] add docker buildx support --- Makefile | 3 +++ hack/Dockerfile | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 hack/Dockerfile diff --git a/Makefile b/Makefile index 3640a9d..6206aef 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,9 @@ build: release: bash hack/make-rules/release-images.sh +buildx-release: + docker buildx build --no-cache --push --platform linux/arm64,linux/amd64 -f hack/Dockerfile . -t ${IMG} + clean: -rm -Rf bin -rm -Rf _output diff --git a/hack/Dockerfile b/hack/Dockerfile new file mode 100644 index 0000000..54f397b --- /dev/null +++ b/hack/Dockerfile @@ -0,0 +1,13 @@ +FROM --platform=${BUILDPLATFORM} golang:1.18 as builder +ADD . /build +ARG TARGETOS TARGETARCH +WORKDIR /build/ +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build + +FROM --platform=${TARGETPLATFORM} alpine:3.17 +ARG TARGETOS TARGETARCH +WORKDIR / +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \ + apk add ca-certificates bash libc6-compat iptables ip6tables && update-ca-certificates && rm /var/cache/apk/* +COPY --from=builder /build/_output/bin/${TARGETOS}/${TARGETARCH}/yurt-device-controller /yurt-device-controller +ENTRYPOINT ["/yurt-device-controller"] \ No newline at end of file From 2951f8fb5320706d41e256de14d1d47a3ef7111d Mon Sep 17 00:00:00 2001 From: wawlian Date: Tue, 18 Apr 2023 14:19:50 +0800 Subject: [PATCH 2/2] update actions to v3 --- .github/workflows/ci.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f8ed9cd..83bba29 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run Check License run: hack/make-rules/check_license.sh @@ -28,17 +28,17 @@ jobs: - name: Checkout uses: actions/setup-go@v3 with: - submodules: true + submodules: - name: Setup Go uses: actions/checkout@v3 with: go-version: ${{ env.GO_VERSION }} + cache: false - name: Lint golang code uses: golangci/golangci-lint-action@v3 with: version: ${{ env.GOLANGCI_VERSION }} - args: --timeout=15m - + args: --disable-all -E deadcode -E gofmt -E goimports -E ineffassign -E misspell -E vet --timeout=15m markdownlint-misspell-shellcheck: runs-on: ubuntu-latest # this image is build from Dockerfile @@ -54,17 +54,17 @@ jobs: build-and-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: true - name: Fetch History run: git fetch --prune --unshallow - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ${{ env.GO_VERSION }} - name: Cache Go Dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} @@ -74,7 +74,7 @@ jobs: - name: Run test run: make test - name: Upload test coverage - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} files: cover.out