-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" | ||
directory: "/mainpage" | ||
target-branch: "dev" | ||
schedule: | ||
interval: "daily" | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
target-branch: "dev" | ||
schedule: | ||
interval: "daily" | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build and push dev Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
paths: | ||
- '.github/workflows/build-image.yml' | ||
- '.github/workflows/build-image-dev.yml' | ||
- 'Dockerfile' | ||
- '**.py' | ||
- 'static/**' | ||
- 'requirements.txt' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build-and-push: | ||
if: github.repository == 'SubConv/SubConv-sing-box' | ||
uses: ./.github/workflows/build-image.yml | ||
secrets: inherit | ||
with: | ||
tags: dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Build and Push Container Image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
tags: | ||
description: 'Tag to use for the image' | ||
type: string | ||
required: true | ||
default: 'dev' | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
env: | ||
IMAGE_REPOSITORY: wouisb/subconv-sing-box | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tags: ${{ steps.tag.outputs.TAG_NAME }} | ||
steps: | ||
- id: tag | ||
run: | | ||
# get tag from input (comma separated) and image_repository | ||
new_tag="" | ||
for tag in $(echo ${{ inputs.tags }} | tr "," "\n"); do | ||
new_tag="$new_tag,${{ env.IMAGE_REPOSITORY }}:$tag" | ||
done | ||
# outupt | ||
echo "TAG_NAME=$new_tag" >> $GITHUB_OUTPUT | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
needs: setup | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Cache Nuitka cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: nuitka-cache | ||
key: nuitka-cache | ||
|
||
- name: Inject Nuitka cache into Docker | ||
uses: reproducible-containers/[email protected] | ||
with: | ||
cache-source: nuitka-cache | ||
cache-target: /root/.cache/Nuitka | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ needs.setup.outputs.tags }} | ||
platforms: | | ||
linux/amd64 | ||
linux/arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
paths: | ||
- '.github/workflows/build.yml' | ||
- '**.py' | ||
- 'static/**' | ||
- 'main.py' | ||
- 'requirements.txt' | ||
workflow_call: | ||
|
||
|
||
jobs: | ||
build: | ||
if: github.repository == 'SubConv/SubConv-sing-box' | ||
strategy: | ||
matrix: | ||
os: [windows-latest, ubuntu-latest, macos-latest] | ||
arch: [x64] | ||
include: | ||
- os: macos-latest | ||
arch: arm64 | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
architecture: ${{ matrix.arch }} | ||
cache: 'pip' | ||
cache-dependency-path: requirements.txt | ||
|
||
- name: Install Dependencies | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Build Executable | ||
uses: Nuitka/Nuitka-Action@main | ||
with: | ||
nuitka-version: main | ||
script-name: main.py | ||
onefile: true | ||
|
||
- name: Copy Files | ||
run: | | ||
mkdir output | ||
cp build/main${{ matrix.os == 'windows-latest' && '.exe' || '.bin' }} output/main${{ matrix.os == 'windows-latest' && '.exe' || '' }} | ||
cp -r static output/static | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: subconv-sing-box-${{ matrix.os }}-${{ matrix.arch }} | ||
path: output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM --platform=$BUILDPLATFORM python:3.11.8-alpine3.19 AS builder | ||
LABEL name="subconv-sing-box" | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
# Install dependencies | ||
RUN apk add --update-cache ca-certificates tzdata patchelf clang ccache | ||
|
||
# Insall python and dependencies | ||
RUN pip3 install -r requirements.txt && \ | ||
pip3 install nuitka | ||
|
||
# Use nuikta to compile the python code | ||
RUN --mount=type=cache,target=/root/.cache/Nuitka \ | ||
python3 -m nuitka --clang --onefile --standalone main.py && \ | ||
chmod +x main.bin | ||
|
||
|
||
FROM alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /app/main.bin /app/main.bin | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY static /app/static | ||
COPY config.yaml /app/config.yaml | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/app/main.bin"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
subconv: | ||
image: wouisb/subconv-sing-box:latest | ||
container_name: subconv-sing-box | ||
restart: unless-stopped | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- ./config.yml:/app/config.yml |