Skip to content

Commit

Permalink
add docker build actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengrui committed Jun 18, 2024
1 parent c47e44a commit 8d465b5
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/buildDockerImage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build docker image

on:
push:
branches:
- 'master'
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=${{ secrets.DOCKER_IMAGE }}
VERSION=latest
SHORTREF=${GITHUB_SHA::8}
# If this is git tag, use the tag name as a docker tag
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
# If the VERSION looks like a version number, assume that
# this is the most recent version of the image and also
# tag it 'latest'.
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MAJOR_VERSION=`echo $VERSION | awk '{split($0,a,"."); print a[1]}'`
MINOR_VERSION=`echo $VERSION | awk '{split($0,a,"."); print a[2]}'`
TAGS="$TAGS,${DOCKER_IMAGE}:${MAJOR_VERSION},${DOCKER_IMAGE}:${MAJOR_VERSION}.${MINOR_VERSION},${DOCKER_IMAGE}:latest"
fi
# Set output parameters.
echo ::set-output name=tags::${TAGS}
echo ::set-output name=docker_image::${DOCKER_IMAGE}
- name: Environment
run: |
echo home=$HOME
echo git_ref=$GITHUB_REF
echo git_sha=$GITHUB_SHA
echo image=${{ steps.prepare.outputs.docker_image }}
echo tags=${{ steps.prepare.outputs.tags }}
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4

- name: Docker Login
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.prepare.outputs.tags }}
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:18-alpine as builder

RUN node -v

RUN mkdir -p /home/node/app && \
chown -R node:node /home/node/app

USER node

WORKDIR /home/node/app

COPY --chown=node:node . .

RUN npm install

RUN npm run build

FROM nginx:alpine

COPY --from=builder /home/node/app/dist/ /usr/share/nginx/html/

EXPOSE 80
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# GOST V3 API Manage

[gost](https://github.com/go-gost/gost) 官方的 web-ui 还没完成,先弄个简单的用一下,好过在 Postman 上捣腾;
纯前端的项目,部署在`github-pages`上, 放心使用;
## 官方入口

[ui.gost.run](https://ui.gost.run)

## 使用方式

1. 启动 API 服务
1. 启动API服务

> `gost -api :18080`

2. 打开 web 端管理地址 [点击打开](http://gost.whyoop.com/)
2. 打开web端管理地址 [点击打开](https://ui.gost.run/)

- API 地址 `http://IP:PORT`, 如果配置了`pathPrefix`,加上`pathPrefix`路径;
- (如果有) 填写 用户,密码;
- 点击 `连接` 按钮;

![home](https://gost.whyoop.com/page-home.png)
<img src="assets/page-home.png" width="512" />

3. 在管理面板,动态管理 GOST
3. 在管理面板,动态管理GOST

![manage](https://gost.whyoop.com/page-manage.png)
<img src="assets/page-manage.png" width="512" />

## 常见问题

Expand Down
Binary file added assets/page-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/page-manage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8d465b5

Please sign in to comment.