Files
shadowsocks-libev/.github/workflows/docker.yml
Max Lv bff687bd34 Add Docker publishing, recommended installation and project history (#3052)
Document the shadowsocks-libev history and shadowsocks-c rename, and recommend Docker installation with mounted configuration and TCP/UDP port mappings.

Add native AMD64/ARM64 builds of the unprivileged static runtime image, real container relay and shutdown tests, and GHCR publication after both architecture checks pass. All 24 build/test checks pass at reviewed head 3f3f6bf8e01e5614821d1e15fda3ad8f07812902; publication is intentionally skipped on pull requests.
2026-09-11 16:22:30 +08:00

105 lines
3.4 KiB
YAML

name: docker
on:
pull_request:
branches: [master]
push:
branches: [master]
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: ghcr.io/shadowsocks/shadowsocks-c
jobs:
image:
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- name: Build tested static runtime image
uses: docker/build-push-action@v7
with:
context: .
file: docker/static/Dockerfile
target: runtime
platforms: linux/${{ matrix.arch }}
load: true
tags: shadowsocks-c:test
labels: org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=gha,scope=docker-${{ matrix.arch }}
cache-to: type=gha,scope=docker-${{ matrix.arch }},mode=max
- name: Exercise read-only, unprivileged runtime containers
run: python3 tests/docker_smoke.py --image shadowsocks-c:test
- name: Log in to GHCR
if: github.repository == 'shadowsocks/shadowsocks-c' && github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish tested architecture image
if: github.repository == 'shadowsocks/shadowsocks-c' && github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
env:
COMMIT: ${{ github.sha }}
ARCH: ${{ matrix.arch }}
run: |
docker tag shadowsocks-c:test "$IMAGE:sha-$COMMIT-$ARCH"
docker push "$IMAGE:sha-$COMMIT-$ARCH"
publish:
needs: image
if: github.repository == 'shadowsocks/shadowsocks-c' && github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Image tags
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
flavor: latest=false
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
type=sha,format=long
type=semver,pattern={{version}}
- name: Publish multi-platform manifest
env:
COMMIT: ${{ github.sha }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
args=()
while IFS= read -r tag; do
if [ -n "$tag" ]; then args+=(--tag "$tag"); fi
done <<< "$TAGS"
docker buildx imagetools create "${args[@]}" \
"$IMAGE:sha-$COMMIT-amd64" "$IMAGE:sha-$COMMIT-arm64"
docker buildx imagetools inspect "$IMAGE:sha-$COMMIT"