Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: niliovo <[email protected]>
  • Loading branch information
niliovo committed Dec 29, 2024
1 parent de47a99 commit 38cc160
Show file tree
Hide file tree
Showing 19 changed files with 226 additions and 704 deletions.
8 changes: 0 additions & 8 deletions .editorconfig

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/auto_build_docker_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: 自动构建docker镜像

on:
schedule:
- cron: "48 18 * * 0"
#watch:
# types: started
# workflow_dispatch:

push:
branches: [ main ]
# pull_request:
# branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Check Out Repo
uses: actions/checkout@v4

# - name: Login to GHCR
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Login to Private Docker Registry
# uses: docker/login-action@v3
# with:
# registry: ${{ secrets.DOCKER_REGISTRY }}
# username: ${{ secrets.PRIVATE_USERNAME }}
# password: ${{ secrets.PRIVATE_PASSWORD }}

- name: Get Respository Name
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> "$GITHUB_ENV"

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
# ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
{{date 'YYYY/MM/DD/hh/mm/ss'}}
# type=schedule,pattern={{date 'YYYY/MM/DD'}}
# type=semver,pattern={{version}}
# type=semver,pattern=$()
# type=ref,event=branch
# type=sha
# type=ref,event=pr
# type=semver,pattern={{major}}.{{minor}}
# type=semver,pattern={{major}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Build and push all
id: docker_build_all
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# target:
- name: all Image digest
run: echo ${{ steps.docker_build_all.outputs.digest }}
88 changes: 88 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# https://docs.gitlab.com/ee/ci/yaml/
# https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
# https://docs.gitlab.com/ee/ci/migration/github_actions.html
# https://gitlab.com/gitlab-org/gitlab/-/tree/master/lib/gitlab/ci/templates/Jobs

stages:
- github-sync
- gitlab-build
- gitlab-deploy

services:
- name: docker:dind
#command: ["--registry-mirror=https://dhcr-cf.oni.li"]

variables:
DOCKER_IMAGE_NAME: $DOCKER_USER/$CI_PROJECT_NAME
PUB_DOCKER_IMAGE_NAME: $PUB_DOCKER_URL/$CI_PROJECT_NAME
PRI_DOCKER_USER: "nili"
PRI_DOCKER_IMAGE_NAME: $PRI_DOCKER_URL/$CI_PROJECT_NAME

同步至 GitHub:
stage: github-sync
tags:
- oracle
image: alpine
allow_failure: true
before_script:
#- sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories
#- TIME=$(TZ='UTC-8' date +'%Y%m%d-%H-%M-%S')
- apk add git rsync
- git config --global user.email $GIT_USER_EMAIL
- git config --global user.name $GIT_USER_NAME
- git clone https://$GIT_USER_NAME:[email protected]/$GIT_USER_NAME/$CI_PROJECT_NAME.git ../tmp
script:
- cd ../tmp
- find . -mindepth 1 -path './.git' -prune -o -exec rm -rf {} +
- cd ../$CI_PROJECT_NAME
- rsync -av --include='.*' --exclude='.git/*' . ../tmp
- cd ../tmp
- git add -A
- git commit -sm "$CI_COMMIT_MESSAGE"
#- git commit -sm "Gitlab CI Auto Update $TIME"
- git push
rules:
- if: $CI_COMMIT_BRANCH

Gitlab Runner 构建 Docker 镜像:
stage: gitlab-build
tags:
- oracle
#image: docker:dind
before_script:
- docker run --privileged --rm tonistiigi/binfmt --install all
- docker buildx create --use --name mybuilder
#- docker login -u "$PRI_DOCKER_USER" -p "$DOCKER_PASSWORD" $PRI_DOCKER_URL
#- TIME=$(TZ='UTC-8' date +'%Y%m%d-%H-%M-%S')
script:
- docker buildx build --file Dockerfile --progress=plain --tag "$PRI_DOCKER_IMAGE_NAME:latest" --platform linux/amd64,linux/arm64 --push .
#- docker buildx build --file Dockerfile --progress=plain --tag "$PRI_DOCKER_IMAGE_NAME:latest" --tag "$PRI_DOCKER_IMAGE_NAME:$TIME" --platform linux/amd64,linux/arm64 --push .
#linux/amd64,linux/arm64,linux/386,linux/arm/v7
rules:
- if: $CI_COMMIT_BRANCH
exists:
- .gitigno

Gitlab Runner 推送部署:
stage: gitlab-deploy
tags:
- oracle
image: alpine
before_script:
- apk add rsync openssh-client
- echo "$SSH_KEY" > key
- chmod 600 key
- ssh-keygen -p -f key -N '' -P "$SSH_KEY_PASSWD"
script:
#- export FILE=nginx/conf.d/stream/stream.conf
#- export TARGETDIR=/root/docker/public/openresty/nginx/conf.d/stream/
- export COMMAND="./sh/dc.sh"
#- chmod +x $FILE
- ssh -o StrictHostKeyChecking=no -p 2200 -i key -4 [email protected] $COMMAND
- ssh -o StrictHostKeyChecking=no -p 2200 -i key -4 [email protected] $COMMAND
- ssh -o StrictHostKeyChecking=no -p 2200 -i key -4 [email protected] $COMMAND
- rm key
rules:
- if: $CI_COMMIT_BRANCH
exists:
- .gitigno
54 changes: 0 additions & 54 deletions .vscode/launch.json

This file was deleted.

29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM alpine AS prebuild
WORKDIR /
RUN apk add git && \
git clone https://github.com/netptop/siteproxy

FROM node:slim
WORKDIR /home/node/siteproxy/
ENV PROXY_URL={PROXY_URL:-http://localhost:5006}
ENV TOKEN_PREFIX={TOKEN_PREFIX:-/user22334455/}
ENV LOCAL_LISTEN_PORT={LOCAL_LISTEN_PORT:-5006}

COPY --from=prebuild /siteproxy/bundle.js .

RUN cat <<'EOF' > entrypoint.sh
#!/bin/sh
if [ ! -f "config.json" ]; then
echo "{
\"proxy_url\": \"${PROXY_URL}\",
\"token_prefix\": \"${TOKEN_PREFIX}\",
\"local_listen_port\": ${LOCAL_LISTEN_PORT}
}"> config.json
fi
node /home/node/siteproxy/bundle.js
EOF

EXPOSE 5006

RUN chmod +x entrypoint.sh
CMD ["./entrypoint.sh"]
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

Loading

0 comments on commit 38cc160

Please sign in to comment.