From 5e6055d1b20f8998b5bc57d71f82ad35cfb4f2f2 Mon Sep 17 00:00:00 2001 From: Hou Junjie Date: Tue, 5 Jan 2021 20:25:38 +0800 Subject: [PATCH] build docker image --- .github/workflows/image.yaml | 48 ++++++++++++++++++++++++++++++++++++ Dockerfile | 9 +++++++ Makefile-CSI | 18 -------------- 3 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/image.yaml create mode 100644 Dockerfile delete mode 100644 Makefile-CSI diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml new file mode 100644 index 00000000..5ea1b3d0 --- /dev/null +++ b/.github/workflows/image.yaml @@ -0,0 +1,48 @@ +name: csi-huawei image +on: + push: + branches: + - master + tags: + - v*.*.* + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout repo + uses: actions/checkout@v2 + + - name: login to docker hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: set up docker buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - id: image_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: $GITHUB_ACTOR/csi-huawei # list of Docker images to use as base name for tags + tag-sha: true # add git short SHA as Docker tag + + - name: build driver + id: docker_build_s3_driver + uses: docker/build-push-action@v2 + with: + context: ./ + file: Dockerfile + push: true + tags: ${{ steps.image_meta.outputs.tags }} + labels: ${{ steps.image_meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3397f498 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM golang:alpine AS builder + +WORKDIR /src +COPY . /src/ +RUN go build -o bin/huawei-csi ./src/csi + +FROM alpine +COPY --from=builder /src/bin/huawei-csi /huawei-csi +ENTRYPOINT [ "/huawei-csi" ] diff --git a/Makefile-CSI b/Makefile-CSI deleted file mode 100644 index aed15f78..00000000 --- a/Makefile-CSI +++ /dev/null @@ -1,18 +0,0 @@ -PLATFORM=PLATFORM -export GOPATH:=$(GOPATH):$(shell pwd) - -all:COMMON_1 DIFF - -COMMON_1: - mkdir -p ./bin - -DIFF: -ifeq (${PLATFORM}, X86) - go build -o ./bin/huawei-csi ./src/csi - go build -o ./bin/passwdEncrypt ./src/tools/passwdEncrypt -endif - -ifeq (${PLATFORM}, ARM) - GOOS=linux GOARCH=arm64 go build -o ./bin/huawei-csi ./src/csi - GOOS=linux GOARCH=arm64 go build -o ./bin/passwdEncrypt ./src/tools/passwdEncrypt -endif \ No newline at end of file