diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml new file mode 100644 index 0000000..6c97451 --- /dev/null +++ b/.gitea/workflows/docker.yml @@ -0,0 +1,42 @@ +name: "Docker Build" + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + workflow_dispatch: ~ + push: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + name: docker build and publish + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build + run: | + PGM_VERSION=$(python .github/get_version.py) + docker buildx build \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --output "type=image,push=true" \ + --platform "linux/amd64,linux/arm64/v8" \ + --build-arg "S6_ARCH=amd64" \ + --tag "${{ secrets.DOCKER_REPO }}:latest" \ + --tag "${{ secrets.DOCKER_REPO }}:${PGM_VERSION}" \ + -f Dockerfile \ + . diff --git a/.gitea/workflows/docker_dev.yml b/.gitea/workflows/docker_dev.yml new file mode 100644 index 0000000..3ea466c --- /dev/null +++ b/.gitea/workflows/docker_dev.yml @@ -0,0 +1,41 @@ +name: "Docker Dev Build" + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + workflow_dispatch: ~ + push: + branches: [ development ] + +jobs: + build: + runs-on: ubuntu-latest + name: docker build and publish + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build + run: | + PGM_VERSION=$(python .github/get_version.py) + docker buildx build \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --output "type=image,push=true" \ + --platform "linux/amd64,linux/arm64/v8" \ + --build-arg "S6_ARCH=amd64" \ + --tag "${{ secrets.DOCKER_REPO }}:${PGM_VERSION}-dev" \ + -f Dockerfile.alpine \ + . diff --git a/.github/get_version.py b/.github/get_version.py new file mode 100644 index 0000000..801f1be --- /dev/null +++ b/.github/get_version.py @@ -0,0 +1,12 @@ +import re + + +def get_version(): + with open("pagermaid/__init__.py", "r", encoding="utf-8") as f: + if version_match := re.search(r'pgm_version = "(.*?)"', f.read()): + return version_match[1] + raise FileNotFoundError + + +if __name__ == "__main__": + print(get_version()) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a71d2b7..f866f1c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -18,24 +18,33 @@ jobs: DOCKERHUB_REPOSITORY: ${{ secrets.DOCKER_REPO }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - - name: Setup Docker Buildx - uses: crazy-max/ghaction-docker-buildx@v3 + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Buildx cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: buildx-cache with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx + - name: Get version + run: | + RAW_PGM_VERSION=$(python .github/get_version.py) + echo "PGM_VERSION=${RAW_PGM_VERSION}" >> "$GITHUB_ENV" + - name: Build run: | docker buildx build \ @@ -45,5 +54,6 @@ jobs: --platform "linux/amd64,linux/arm64/v8" \ --build-arg "S6_ARCH=amd64" \ --tag "${DOCKERHUB_REPOSITORY}:latest" \ + --tag "${DOCKERHUB_REPOSITORY}:${PGM_VERSION} \ -f Dockerfile \ . diff --git a/Dockerfile b/Dockerfile index 4f1cc80..f0d5b96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest +FROM ubuntu:jammy ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ LANG=zh_CN.UTF-8 \ SHELL=/bin/bash \ @@ -47,7 +47,6 @@ RUN source ~/.bashrc \ libffi-dev \ zlib1g-dev \ tcl8.6-dev \ - tk8.6-dev \ libimagequant-dev \ libraqm-dev \ libjpeg-dev \ @@ -56,7 +55,6 @@ RUN source ~/.bashrc \ libfreetype6-dev \ liblcms2-dev \ libwebp-dev \ - python3-tk \ libharfbuzz-dev \ libfribidi-dev \ libxcb1-dev \ @@ -89,7 +87,6 @@ RUN source ~/.bashrc \ libffi-dev \ zlib1g-dev \ tcl8.6-dev \ - tk8.6-dev \ libimagequant-dev \ libraqm-dev \ libjpeg-dev \ @@ -98,7 +95,6 @@ RUN source ~/.bashrc \ libfreetype6-dev \ liblcms2-dev \ libwebp-dev \ - python3-tk \ libharfbuzz-dev \ libfribidi-dev \ libxcb1-dev \