Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #4759 venus-auth: add docker feature #75

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/build_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
set -e

- name: Publish 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.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
LinZexiao marked this conversation as resolved.
Show resolved Hide resolved
38 changes: 38 additions & 0 deletions .github/workflows/docker-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker Image CI

on:
create:
tags:
- '**'
push:
branches: [ docker ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是主分支[ main ]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对,这个是只监听docker分支的,主分支的已经写进原来那个统一的那个 工作流文件了。如果以后docker分支不保留的话,可以删掉,否则建议保留,这样可以方便dockers分支进行发布镜像测试

pull_request:
branches: [ docker ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
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
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
17 changes: 17 additions & 0 deletions docker/script/compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

echo $@
/app/venus-auth run &

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

wait
20 changes: 20 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -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"]