From c5e8cc80c764a1b3d13c06cda5bd3d85934937a7 Mon Sep 17 00:00:00 2001 From: tanlang Date: Thu, 5 May 2022 19:55:15 +0800 Subject: [PATCH 1/5] add:dockerfile &docker dir --- .github/workflows/docker-release.yaml | 28 +++++++++++++++++++++++++++ Makefile | 20 ++++++++++++++++++- docker/script/compose.sh | 14 ++++++++++++++ dockerfile | 20 +++++++++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-release.yaml create mode 100755 docker/script/compose.sh create mode 100644 dockerfile diff --git a/.github/workflows/docker-release.yaml b/.github/workflows/docker-release.yaml new file mode 100644 index 0000000..f0cb6b0 --- /dev/null +++ b/.github/workflows/docker-release.yaml @@ -0,0 +1,28 @@ +name: Docker Image CI + +on: + push: + branches: [ docker ] + pull_request: + branches: [ docker ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + ref: docker + - name: Build the Docker image + run: | + docker build . --file dockerfile --tag filvenus/venus-auth:latest + # docker tag filvenus/venus-auth:latest filvenus/venus-auth:${{steps.vars.outputs.tag}} + - name: Login to registry + run: docker login --username=filvenus --password ${{ secrets.DOCKER_PASSWORD }} + - name: Push Image + run: | + # docker push filvenus/venus-auth:${{steps.vars.outputs.tag}} + docker push filvenus/venus-auth:latest \ No newline at end of file diff --git a/Makefile b/Makefile index 833803c..2b8bb9a 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,22 @@ linux: clean clean: rm -rf venus-auth -.PHONY: clean +.PHONY: clean + + +.PHONY: docker + +BUILD_DOCKER_PROXY= + +static: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(GOFLAGS) -o venus-auth ./cmd/server/*.go + +docker-buildenv: + docker build --build-arg https_proxy=$(BUILD_DOCKER_PROXY) -t filvenus/venus-buildenv -f docker/venus-buildenv.dockerfile . + +docker-runtime: + docker build --build-arg https_proxy=$(BUILD_DOCKER_PROXY) -t filvenus/venus-runtime -f docker/venus-runtime.dockerfile . + + +docker: + docker build --build-arg https_proxy=$(BUILD_DOCKER_PROXY) -t venus-auth . diff --git a/docker/script/compose.sh b/docker/script/compose.sh new file mode 100755 index 0000000..99bab4c --- /dev/null +++ b/docker/script/compose.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +echo $@ +/app/venus-auth run & + +sleep 3 + +echo "regist admin" +/app/venus-auth user add --name="admin" +token=`/app/venus-auth token gen --perm admin admin` +echo ${token#*: } +echo "${token#*: }" > /env/token + +wait \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..dfafa0c --- /dev/null +++ b/dockerfile @@ -0,0 +1,20 @@ +FROM filvenus/venus-buildenv AS buildenv + +RUN git clone https://github.com/filecoin-project/venus-auth.git --depth 1 +RUN export GOPROXY=https://goproxy.cn && cd venus-auth && make linux + + +FROM filvenus/venus-runtime + +# DIR for app +WORKDIR /app + +# copy the app from build env +COPY --from=buildenv /go/venus-auth/venus-auth /app/venus-auth +COPY ./docker/script /script + +EXPOSE 8989 + +ENTRYPOINT ["/app/venus-auth","run"] + + From ea77527ea1f3eac65246e1e86501f9e2f2769dc9 Mon Sep 17 00:00:00 2001 From: tanlang Date: Wed, 11 May 2022 12:24:46 +0800 Subject: [PATCH 2/5] add: more readable log --- docker/script/compose.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker/script/compose.sh b/docker/script/compose.sh index 99bab4c..9b10e6a 100755 --- a/docker/script/compose.sh +++ b/docker/script/compose.sh @@ -3,11 +3,14 @@ echo $@ /app/venus-auth run & -sleep 3 +sleep 1 echo "regist admin" /app/venus-auth user add --name="admin" token=`/app/venus-auth token gen --perm admin admin` +/app/venus-auth user active admin + +echo "token:" echo ${token#*: } echo "${token#*: }" > /env/token From d71fed74fa11ca1fb187aecff77b51bcc1600a0b Mon Sep 17 00:00:00 2001 From: tanlang Date: Fri, 13 May 2022 10:46:02 +0800 Subject: [PATCH 3/5] feat: add publish docker image action --- .github/workflows/build_upload.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_upload.yml b/.github/workflows/build_upload.yml index 3156abc..7ce260b 100644 --- a/.github/workflows/build_upload.yml +++ b/.github/workflows/build_upload.yml @@ -174,4 +174,13 @@ jobs: --data-urlencode "link=$link" \ --data-urlencode "description=message:${{steps.vars.outputs.git_message}}, branch:${{steps.vars.outputs.branch}}, commit:${{steps.vars.outputs.short}}, tag:${{steps.vars.outputs.github_tag}}" \ --data-urlencode "version=${{steps.vars.outputs.short}}" - set -e \ No newline at end of file + set -e + + - name: Publish the Docker image + if: ${{ steps.vars.outputs.pub_method=='pushRelease' }} + run: | + docker build . --file dockerfile --tag filvenus/venus-auth:latest + docker tag filvenus/venus-auth:latest filvenus/venus-auth:${{steps.vars.outputs.github_tag }} + docker login --username=filvenus --password ${{ secrets.DOCKER_PASSWORD }} + docker push filvenus/venus-auth:${{steps.vars.outputs.github_tag }} + docker push filvenus/venus-auth:latest \ No newline at end of file From 5510f98e344dc4dc8b8a8527d7052bbededeb0d9 Mon Sep 17 00:00:00 2001 From: Lin Xiao Date: Mon, 16 May 2022 12:56:30 +0800 Subject: [PATCH 4/5] fix: change action trigger to making tag --- .github/workflows/build_upload.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_upload.yml b/.github/workflows/build_upload.yml index 7ce260b..3e71c11 100644 --- a/.github/workflows/build_upload.yml +++ b/.github/workflows/build_upload.yml @@ -177,7 +177,7 @@ jobs: set -e - name: Publish the Docker image - if: ${{ steps.vars.outputs.pub_method=='pushRelease' }} + if: ${{ github.ref_type == 'tag' && github.event_name == 'create' }} run: | docker build . --file dockerfile --tag filvenus/venus-auth:latest docker tag filvenus/venus-auth:latest filvenus/venus-auth:${{steps.vars.outputs.github_tag }} From bb1803c07be98ef71134320746793951b429543f Mon Sep 17 00:00:00 2001 From: Lin Xiao Date: Mon, 16 May 2022 13:22:51 +0800 Subject: [PATCH 5/5] fix: change action trigger to making tag on docker --- .github/workflows/docker-release.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/docker-release.yaml b/.github/workflows/docker-release.yaml index f0cb6b0..5567522 100644 --- a/.github/workflows/docker-release.yaml +++ b/.github/workflows/docker-release.yaml @@ -1,6 +1,9 @@ name: Docker Image CI on: + create: + tags: + - '**' push: branches: [ docker ] pull_request: @@ -17,12 +20,19 @@ jobs: with: ref: docker - name: Build the Docker image + if: ${{ github.ref_type == 'tag' && github.event_name == 'create' }} run: | docker build . --file dockerfile --tag filvenus/venus-auth:latest # docker tag filvenus/venus-auth:latest filvenus/venus-auth:${{steps.vars.outputs.tag}} + + - name: Login to registry + if: ${{ github.ref_type == 'tag' && github.event_name == 'create' }} run: docker login --username=filvenus --password ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Image + if: ${{ github.ref_type == 'tag' && github.event_name == 'create' }} run: | # docker push filvenus/venus-auth:${{steps.vars.outputs.tag}} docker push filvenus/venus-auth:latest \ No newline at end of file