Compare commits
26 commits
59e97f805e
...
eb011f720b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb011f720b | ||
|
|
5d2e28dd99 | ||
|
|
1bdbffbc99 | ||
|
|
e44d1b8b5a | ||
|
|
ccee56aff2 | ||
|
|
3b2078b203 | ||
|
|
601fce07f8 | ||
|
|
61a627483d | ||
|
|
971d3e4b8f | ||
|
|
6e766a28ae | ||
|
|
cfcf0a2800 | ||
|
|
729bfbe49e | ||
|
|
871d506f83 | ||
|
|
6a70fc8438 | ||
|
|
cbb487d307 | ||
|
|
ab37e8408a | ||
|
|
494b672aba | ||
|
|
f289ff86b0 | ||
|
|
f14f0ac299 | ||
|
|
cd8a69f1ad | ||
|
|
db7619b975 | ||
|
|
dce0f4c5f6 | ||
|
|
9b23ba183b | ||
|
|
77418ef60b | ||
|
|
24f6d524e2 | ||
|
|
1c867043fc |
5 changed files with 36 additions and 239 deletions
|
|
@ -1 +1,4 @@
|
||||||
test
|
test
|
||||||
|
test
|
||||||
|
ci test Sat Mar 28 11:26:45 +07 2026
|
||||||
|
test Sat Mar 28 14:46:11 +07 2026
|
||||||
|
|
|
||||||
|
|
@ -3,70 +3,24 @@ name: Build & Push Docker Image
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, master]
|
branches: [main, master]
|
||||||
tags: ['v*']
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
|
||||||
api_url:
|
|
||||||
description: 'API URL for frontend build'
|
|
||||||
required: false
|
|
||||||
default: 'http://ut.khoavo.myds.me:8981/api'
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker:host
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Tools check
|
|
||||||
run: |
|
|
||||||
echo "Docker: $(docker --version)"
|
|
||||||
echo "Git: $(git --version)"
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: |
|
run: |
|
||||||
cd /tmp
|
cd /tmp
|
||||||
rm -rf kv-tube
|
rm -rf kv-tube
|
||||||
git clone https://vndangkhoa:Thieugia19@git.khoavo.myds.me/vndangkhoa/kv-tube.git
|
git clone https://vndangkhoa:b14bc4938aeb5f4014fa15186985a0a625f7e9b4@nas:3050/vndangkhoa/kv-tube.git
|
||||||
cd kv-tube
|
cd kv-tube
|
||||||
git checkout ${GITEA_SHA:-main}
|
git checkout ${GITEA_SHA:-main}
|
||||||
echo "Checked out: $(git rev-parse --short HEAD)"
|
|
||||||
|
|
||||||
- name: Login to registry
|
|
||||||
run: echo "Thieugia19" | docker login git.khoavo.myds.me -u vndangkhoa --password-stdin
|
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
run: |
|
run: |
|
||||||
cd /tmp/kv-tube
|
cd /tmp/kv-tube
|
||||||
SHA_SHORT=$(git rev-parse --short HEAD)
|
SHA_SHORT=$(git rev-parse --short HEAD)
|
||||||
IMAGE="git.khoavo.myds.me/vndangkhoa/kv-tube"
|
IMAGE="git.khoavo.myds.me/vndangkhoa/kv-tube"
|
||||||
TAGS="${IMAGE}:${SHA_SHORT}"
|
docker build -t ${IMAGE}:${SHA_SHORT} .
|
||||||
if [ "${GITEA_REF}" = "refs/heads/main" ] || [ "${GITEA_REF}" = "refs/heads/master" ]; then
|
docker push ${IMAGE}:${SHA_SHORT}
|
||||||
TAGS="${TAGS},${IMAGE}:main"
|
|
||||||
fi
|
|
||||||
if echo "${GITEA_REF}" | grep -q "refs/tags/v"; then
|
|
||||||
VERSION=${GITEA_REF#refs/tags/v}
|
|
||||||
TAGS="${TAGS},${IMAGE}:${VERSION},${IMAGE}:latest"
|
|
||||||
fi
|
|
||||||
echo "Building tags: ${TAGS}"
|
|
||||||
|
|
||||||
TAG_ARGS=""
|
|
||||||
IFS=',' read -ra TAG_ARRAY <<< "${TAGS}"
|
|
||||||
for tag in "${TAG_ARRAY[@]}"; do
|
|
||||||
TAG_ARGS="${TAG_ARGS} -t ${tag}"
|
|
||||||
done
|
|
||||||
|
|
||||||
docker build \
|
|
||||||
${TAG_ARGS} \
|
|
||||||
--build-arg NEXT_PUBLIC_API_URL=${{ gitea.event.inputs.api_url || 'http://ut.khoavo.myds.me:8981/api' }} \
|
|
||||||
.
|
|
||||||
|
|
||||||
for tag in "${TAG_ARRAY[@]}"; do
|
|
||||||
echo "Pushing ${tag}..."
|
|
||||||
docker push "${tag}"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Verify
|
|
||||||
run: docker images | grep kv-tube
|
|
||||||
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: rm -rf /tmp/kv-tube
|
|
||||||
|
|
|
||||||
114
.github/workflows/ci.yml
vendored
114
.github/workflows/ci.yml
vendored
|
|
@ -1,114 +0,0 @@
|
||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main, master]
|
|
||||||
pull_request:
|
|
||||||
branches: [main, master]
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
api_url:
|
|
||||||
description: 'API URL'
|
|
||||||
required: false
|
|
||||||
default: 'http://ut.khoavo.myds.me:8981/api'
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install ruff mypy bandit types-requests
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
- name: Run Ruff
|
|
||||||
run: ruff check . --output-format=github
|
|
||||||
|
|
||||||
- name: Run MyPy
|
|
||||||
run: mypy app/ config.py --ignore-missing-imports
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Run Bandit
|
|
||||||
run: bandit -r app/ -x app/routes/api --skip B101,B311
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -r requirements.txt
|
|
||||||
pip install pytest pytest-cov
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: pytest tests/ -v --tb=short
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [lint, test]
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log into Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: docker.io
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Log into Forgejo Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: git.khoavo.myds.me
|
|
||||||
username: ${{ secrets.FORGEJO_USERNAME }}
|
|
||||||
password: ${{ secrets.FORGEJO_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Extract Docker metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
docker.io/${{ github.repository }}
|
|
||||||
git.khoavo.myds.me/${{ github.repository }}
|
|
||||||
tags: |
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/tags/v*' }}
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
platforms: linux/amd64
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
build-args: |
|
|
||||||
NEXT_PUBLIC_API_URL=${{ github.event.inputs.api_url || 'http://ut.khoavo.myds.me:8981/api' }}
|
|
||||||
56
.github/workflows/docker-publish.yml
vendored
56
.github/workflows/docker-publish.yml
vendored
|
|
@ -1,56 +0,0 @@
|
||||||
name: Docker Build & Push
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
api_url:
|
|
||||||
description: 'API URL'
|
|
||||||
required: false
|
|
||||||
default: 'http://ut.khoavo.myds.me:8981/api'
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log into Forgejo Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: git.khoavo.myds.me
|
|
||||||
username: ${{ secrets.FORGEJO_USERNAME }}
|
|
||||||
password: ${{ secrets.FORGEJO_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Extract metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: git.khoavo.myds.me/vndangkhoa/kv-tube
|
|
||||||
tags: |
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/tags/v*' }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
platforms: linux/amd64
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
build-args: |
|
|
||||||
NEXT_PUBLIC_API_URL=${{ github.event.inputs.api_url || 'http://ut.khoavo.myds.me:8981/api' }}
|
|
||||||
|
|
@ -1,42 +1,52 @@
|
||||||
services:
|
services:
|
||||||
server:
|
forgejo:
|
||||||
image: codeberg.org/forgejo/forgejo:9
|
image: codeberg.org/forgejo/forgejo:7.0.16
|
||||||
container_name: forgejo
|
container_name: forgejo
|
||||||
environment:
|
environment:
|
||||||
- USER_UID=1026
|
- USER_UID=1026
|
||||||
- USER_GID=100
|
- USER_GID=100
|
||||||
- GITEA__database__DB_TYPE=sqlite3
|
- GITEA__database__DB_TYPE=sqlite3
|
||||||
- TZ=Asia/Ho_Chi_Minh
|
- TZ=Asia/Ho_Chi_Minh
|
||||||
|
- GITEA__actions__ENABLED=true
|
||||||
|
- INSTALL_LOCK=true
|
||||||
|
- FORGEJO__server__ROOT_URL=http://nas:3050/
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
|
||||||
- forgejo_custom_net
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./forgejo-data:/data
|
||||||
ports:
|
ports:
|
||||||
- "3050:3000"
|
- "3050:3000"
|
||||||
- "2222:22"
|
- "2222:22"
|
||||||
|
networks:
|
||||||
|
- kv-tube_default
|
||||||
|
|
||||||
runner:
|
forgejo-runner:
|
||||||
image: code.forgejo.org/forgejo/runner:6.0.1
|
image: code.forgejo.org/forgejo/runner:latest
|
||||||
container_name: forgejo_runner
|
container_name: forgejo_runner
|
||||||
restart: always
|
restart: always
|
||||||
user: "0:0"
|
user: "0:0"
|
||||||
privileged: true
|
privileged: true
|
||||||
depends_on:
|
depends_on:
|
||||||
- server
|
- forgejo
|
||||||
networks:
|
|
||||||
- forgejo_custom_net
|
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- ./runner-data:/data
|
- ./forgejo-runner-data:/data
|
||||||
entrypoint: >
|
entrypoint:
|
||||||
sh -c "if [ ! -f /data/.runner ]; then forgejo-runner register --no-interactive --instance http://server:3000 --token xP3IdP05YPJJZ504z7UzK90njFFzQnX4d77cJiCN --name synology-runner --labels ubuntu-latest:docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm,docker:host; fi; forgejo-runner daemon"
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [ ! -f /data/.runner ]; then
|
||||||
|
forgejo-runner register --no-interactive \
|
||||||
|
--instance http://forgejo:3000 \
|
||||||
|
--token d5XKhmpu4lTR7P516juCjEes6QsI4qFvVean3zqT \
|
||||||
|
--name synology-runner \
|
||||||
|
--labels ubuntu-latest,ubuntu-22.04,docker:host
|
||||||
|
fi
|
||||||
|
forgejo-runner daemon
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Ho_Chi_Minh
|
- TZ=Asia/Ho_Chi_Minh
|
||||||
|
networks:
|
||||||
|
- kv-tube_default
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
forgejo_custom_net:
|
kv-tube_default:
|
||||||
driver: bridge
|
external: true
|
||||||
ipam:
|
|
||||||
config:
|
|
||||||
- subnet: 172.38.0.0/24
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue