From 082c369d415b29b273aeb098de930fec62f33824 Mon Sep 17 00:00:00 2001 From: linwenxiang <991154416@qq.com> Date: Mon, 6 Sep 2021 21:51:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=20:sparkles:=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=88=B0gitee?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/mirror.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/mirror.yaml diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml new file mode 100644 index 0000000..902a19c --- /dev/null +++ b/.github/workflows/mirror.yaml @@ -0,0 +1,17 @@ +name: 'GitHub Actions Mirror' + +on: [push, delete] + +jobs: + mirror_to_gitee: + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@v1 + - name: 'Mirror to gitee' + uses: pixta-dev/repository-mirroring-action@v1 + with: + target_repo_url: + git@gitee.com:go-admin-team/go-admin.git + ssh_private_key: + ${{ secrets.GITEE_KEY }} From 7ca776bfabfb9ac9199f41e69f758408da0d7914 Mon Sep 17 00:00:00 2001 From: lwnmengjing <991154416@qq.com> Date: Tue, 7 Sep 2021 11:20:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:green=5Fheart:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BFCI=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/go.yml | 18 +++++++++++++----- Dockerfile | 30 +++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 462875c..797c12e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,9 +29,17 @@ jobs: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh dep ensure fi - - name: Build - run: go build -v . - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') + run: | + ref=${{ github.ref }} + go mod vendor + docker build . -t goadminteam/go-admin:${ref##*/}-${{ github.sha }} + docker tag goadminteam/go-admin:${ref##*/}-${{ github.sha }} goadminteam/go-admin:latest + - uses: Azure/docker-login@v1 + with: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - run: | + ref=${{ github.ref }} + docker push goadminteam/go-admin:${ref##*/}-${{ github.sha }} + docker push goadminteam/go-admin:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9e24efb..430e91e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,26 @@ -FROM alpine +FROM golang:alpine as builder + +MAINTAINER lwnmengjing ENV GOPROXY https://goproxy.cn/ -RUN apk update --no-cache -RUN apk add --no-cache ca-certificates -RUN apk add --no-cache tzdata -ENV TZ Asia/Shanghai +WORKDIR /go/release +#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk update && apk add tzdata + +COPY go.mod ./go.mod +RUN go mod tidy +COPY . . +RUN pwd && ls + +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o go-admin . + +FROM alpine + +COPY --from=builder /go/release/go-admin / + +COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -COPY ./main /main -COPY ./config/settings.prod.yml /config/settings.yml EXPOSE 8000 -RUN chmod +x /main -CMD ["/main","server","-c", "/config/settings.yml"] \ No newline at end of file + +CMD ["/go-admin","server","-c", "/config/settings.yml"] \ No newline at end of file