Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
AirportR committed Feb 5, 2024
2 parents c7cbc25 + 3bb0cee commit eebc395
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 54 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build_meta_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build_meta_image

on:
push:
paths:
- 'docker/Metafile'
- 'docker/Metafile.alpine'
- 'requirements.txt'
branches:
- "dev"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
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: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Environment Variables
run: |
IMG=fulltclash
echo "IMG=${IMG}" >> $GITHUB_ENV
echo "IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/${IMG}" >> $GITHUB_ENV
- name: Build Debian Image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Metafile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE }}:debian
- name: Build Alpine Image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Metafile.alpine
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE }}:alpine
34 changes: 24 additions & 10 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- ".github/ISSUE_TEMPLATE/**"
branches:
- "master"
- "dev"

jobs:
docker:
Expand All @@ -20,19 +21,18 @@ jobs:
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Environment Variables
run: |
IMG=fulltclash
OWNER="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
echo "IMG=${IMG}" >> $GITHUB_ENV
echo "IMAGE=ghcr.io/${OWNER}/${IMG}" >> $GITHUB_ENV
- name: Build and push
echo "IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/${IMG}" >> $GITHUB_ENV
- name: Build Latest Image
if: ${{ github.ref_name == 'dev' }}
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
Expand All @@ -41,13 +41,27 @@ jobs:
push: true
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:dev
- name: Build alpine Docker
${{ env.IMAGE }}:debian-${{ github.ref_name }}
build-args: |
GIT_Branch=${{ github.ref_name }}
- name: Build Debian Image
if: ${{ github.ref_name != 'dev' }}
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./docker/Dockerfile
push: true
tags: |
${{ env.IMAGE }}:debian-${{ github.ref_name }}
- name: Build Alpine Image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./docker/Dockerfile.alpine
push: true
tags: |
${{ env.IMAGE }}:alpine
${{ env.IMAGE }}:alpine-${{ github.ref_name }}
build-args: |
GIT_Branch=${{ github.ref_name }}
17 changes: 4 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
FROM python:3.11.7-slim-bookworm AS compile-image

RUN apt-get update && \
apt-get install --no-install-recommends -y \
gcc g++ make ca-certificates

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
ADD https://raw.githubusercontent.com/AirportR/FullTclash/dev/requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt && \
pip3 install --no-cache-dir supervisor
FROM airportr/fulltclash:debian AS compile-image

FROM python:3.11.7-slim-bookworm

ARG GIT_Branch
ENV GIT_Branch=$GIT_Branch
ENV TZ=Asia/Shanghai
ENV admin=12345678
ENV api_id=123456
Expand All @@ -30,7 +21,7 @@ WORKDIR /app
RUN apt-get update && \
apt-get install --no-install-recommends -y \
git tzdata curl wget jq bash nano cron && \
git clone -b dev --single-branch --depth=1 https://github.com/AirportR/FullTclash.git /app && \
git clone -b $GIT_Branch --single-branch --depth=1 https://github.com/AirportR/FullTclash.git /app && \
git clone --single-branch --depth=1 https://github.com/twitter/twemoji.git /app/resources/emoji/twemoji && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
Expand Down
16 changes: 4 additions & 12 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
FROM python:3.11.7-alpine3.19 AS compile-image

RUN apk add --no-cache \
gcc g++ make libffi-dev libstdc++ gcompat libgcc build-base py3-pybind11-dev abseil-cpp-dev re2-dev ca-certificates

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
ADD https://raw.githubusercontent.com/AirportR/FullTclash/dev/requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt && \
pip3 install --no-cache-dir supervisor
FROM airportr/fulltclash:alpine AS compile-image

FROM python:3.11.7-alpine3.19

ARG GIT_Branch
ENV GIT_Branch=$GIT_Branch
ENV TZ=Asia/Shanghai
ENV admin=12345678
ENV api_id=123456
Expand All @@ -28,7 +20,7 @@ WORKDIR /app

RUN apk add --no-cache \
git tzdata curl jq wget bash nano && \
git clone -b dev --single-branch --depth=1 https://github.com/AirportR/FullTclash.git /app && \
git clone -b $GIT_Branch --single-branch --depth=1 https://github.com/AirportR/FullTclash.git /app && \
git clone --single-branch --depth=1 https://github.com/twitter/twemoji.git /app/resources/emoji/twemoji && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
Expand Down
19 changes: 19 additions & 0 deletions docker/Metafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.11.7-slim-bookworm AS compile-image

RUN apt-get update && \
apt-get install --no-install-recommends -y \
gcc g++ make ca-certificates

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
ADD https://raw.githubusercontent.com/AirportR/FullTclash/dev/requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt && \
pip3 install --no-cache-dir supervisor

FROM python:3.11.7-slim-bookworm

COPY --from=compile-image /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=compile-image /opt/venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
18 changes: 18 additions & 0 deletions docker/Metafile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11.7-alpine3.19 AS compile-image

RUN apk add --no-cache \
gcc g++ make libffi-dev libstdc++ gcompat libgcc build-base py3-pybind11-dev abseil-cpp-dev re2-dev ca-certificates

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
ADD https://raw.githubusercontent.com/AirportR/FullTclash/dev/requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt && \
pip3 install --no-cache-dir supervisor

FROM python:3.11.7-alpine3.19

COPY --from=compile-image /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=compile-image /opt/venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
57 changes: 41 additions & 16 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,45 @@
> 这能让你在Windows、Mac、Linux、openwrt、Nas几乎任何支持Docker(目前仅Amd64和Arm64)的环境下使用此项目!
## 创建配置文件
新建配置文件保存目录`mkdir /etc/FullTclash`

新建配置文件保存目录`mkdir /etc/fulltclash`
下载并编辑配置文件

```bash
wget -O /etc/fulltclash/config.yaml https://raw.githubusercontent.com/AirportR/FullTclash/dev/resources/config.yaml.example
```
wget -O /etc/FullTclash/config.yaml https://raw.githubusercontent.com/AirportR/FullTclash/dev/resources/config.yaml.example
```

修改 config.yaml (path是必须修改的配置,不能使用默认的)
```

```bash
clash:
path: './bin/fulltclash-origin'
branch: origin
```

或者 [Meta内核](https://github.com/AirportR/FullTCore/tree/meta)
```

```bash
clash:
path: './bin/fulltclash-meta'
branch: meta
```

## 部署


### 拉取镜像

> 镜像可选dev或者alpine,dev是通过Debian构建的
```bash
docker pull ghcr.io/airportr/fulltclash:dev
docker pull airportr/fulltclash:latest
```

镜像还可以选择以下标签,其中 `latest` 标签是基于 `debian` `dev分支`构建

- debian-dev
- alpine-dev
- debian-master
- alpine-master

### docker

#### 快速启动
Expand All @@ -49,12 +59,12 @@ docker run -idt \
-e core=4 \
-e startup=1124 \
-e speedthread=4 \
-e nospeed=true \
-e nospeed=false \
-e s5_proxy=127.0.0.1:7890 \
-e http_proxy=127.0.0.1:7890 \
--network=host \
--restart always \
ghcr.io/airportr/fulltclash:dev
airportr/fulltclash:latest
```

#### 挂载配置文件启动(推荐)
Expand All @@ -65,7 +75,7 @@ docker run -itd \
--network=host \
--restart=always \
-v /etc/fulltclash/config.yaml:/app/resources/config.yaml \
ghcr.io/airportr/fulltclash:dev
airportr/fulltclash:latest
```

### docker-compose(推荐)
Expand All @@ -83,14 +93,29 @@ docker-compose down
```

查看日志
```

```bash
docker exec -it fulltclash tail -f /var/log/fulltclash.log
```

更新版本
```

```bash
docker exec -it fulltclash bash /app/docker/update.sh
```

重启程序
```

```bash
docker exec -it fulltclash supervisorctl restart fulltclash
```
```

进入容器

```bash
docker exec -it fulltclash bash
```

退出容器

`root@deeb9eaf66aa:/app# exit`
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.9'

services:
fulltclash:
image: ghcr.io/airportr/fulltclash:dev
image: airportr/fulltclash:latest
restart: always
network_mode: host
container_name: fulltclash
Expand Down
23 changes: 21 additions & 2 deletions docker/update.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
#!/bin/bash
. /etc/profile

git_branch=$(git --git-dir='/app/.git' --work-tree='/app' rev-parse --abbrev-ref HEAD)
git_version=$(git --git-dir='/app/.git' --work-tree='/app' rev-parse HEAD)
last_version=$(curl -Ls "https://api.github.com/repos/AirportR/FullTclash/commits/dev" | jq .sha | sed -E 's/.*"([^"]+)".*/\1/')

if [[ master == "$git_branch" ]]; then
echo -e "当前分支为 $git_branch"
echo -e "当前commits位于 $git_version"
last_version=$(curl -Ls "https://api.github.com/repos/AirportR/FullTclash/commits/master" | jq .sha | sed -E 's/.*"([^"]+)".*/\1/')
elif [[ dev == "$git_branch" ]]; then
echo -e "当前分支为 $git_branch"
echo -e "当前commits位于 $git_version"
last_version=$(curl -Ls "https://api.github.com/repos/AirportR/FullTclash/commits/dev" | jq .sha | sed -E 's/.*"([^"]+)".*/\1/')
elif [[ backend == "$git_branch" ]]; then
echo -e "当前分支为 $git_branch"
echo -e "当前commits位于 $git_version"
last_version=$(curl -Ls "https://api.github.com/repos/AirportR/FullTclash/commits/backend" | jq .sha | sed -E 's/.*"([^"]+)".*/\1/')
else
echo -e "暂不支持此分支"
exit 1
fi

update() {
git --git-dir='/app/.git' --work-tree='/app' fetch --all
git --git-dir='/app/.git' --work-tree='/app' reset --hard origin/dev
git --git-dir='/app/.git' --work-tree='/app' reset --hard origin/$git_branch
git --git-dir='/app/.git' --work-tree='/app' pull
git_version=$(git --git-dir='/app/.git' --work-tree='/app' rev-parse HEAD)
}

if [[ $last_version == "$git_version" ]]; then
echo -e "已是最新版本,无需更新"
else
echo -e "检查到新版本,正在更新"
update
echo -e "更新完成,当前commits位于 $git_version"
/opt/venv/bin/supervisorctl restart fulltclash
fi

0 comments on commit eebc395

Please sign in to comment.