diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index 0d7e1abff0..ef487e5d26 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -665,30 +665,14 @@ jobs: python3 -m proxy --version docker: - runs-on: ${{ matrix.os }}-latest + runs-on: Ubuntu-latest permissions: packages: write needs: - build - pre-setup # transitive, for accessing settings - name: 🐳 🐍${{ matrix.python }} @ ${{ matrix.targetplatform }} + name: 🐳 containerize strategy: - matrix: - os: - - Ubuntu - python: - - '3.10' - # NOTE: Change to target platform must also - # be kept consistent with ghcr-manifest tags. - targetplatform: - - 'linux/386' - - 'linux/amd64' - - 'linux/arm/v6' - - 'linux/arm/v7' - - 'linux/arm64/v8' - - 'linux/ppc64le' - - 'linux/s390x' - # max-parallel: 1 fail-fast: false steps: - name: Checkout @@ -698,6 +682,12 @@ jobs: with: name: python-package-distributions path: dist/ + - name: Login to GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 @@ -716,89 +706,41 @@ jobs: docker buildx use proxypybuilder docker buildx inspect docker buildx ls - - name: Build container + - name: Build, run & test container run: >- - docker images; - make container-buildx - -e PROXYPY_PKG_PATH='dist/${{ + CONTAINER_TAG="abhinavsingh/proxy.py:${{ + needs.pre-setup.outputs.container-version + }}"; + docker buildx build + --load + --build-arg PROXYPY_PKG_PATH='dist/${{ needs.pre-setup.outputs.wheel-artifact-name }}' - -e BUILDX_TARGET_PLATFORM='${{ matrix.targetplatform }}' - -e PROXYPY_CONTAINER_VERSION='${{ - needs.pre-setup.outputs.container-version - }}'; - docker images - - name: Run & Test container - run: >- + -t $CONTAINER_TAG . + && docker run -d -p 8899:8899 - abhinavsingh/proxy.py:${{ - needs.pre-setup.outputs.container-version - }} + $CONTAINER_TAG --hostname 0.0.0.0 --enable-web-server --local-executor && ./tests/integration/test_integration.sh 8899 - - name: Login to GHCR - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Tag & Push to GHCR + - name: Build multi-platform containers run: >- - REGISTRY_URL="ghcr.io/abhinavsingh/proxy.py"; - IMAGE_ID=$(docker images | grep ${{ - needs.pre-setup.outputs.container-version - }} | awk '{ print $3 }'); - PLATFORM=$(echo '${{ - matrix.targetplatform - }}' | tr / .); - PLATFORM_CONTAINER_URL=$REGISTRY_URL:${{ + REGISTRY_URL="ghcr.io/abhinavsingh/proxy.py" + CONTAINER_TAG=$REGISTRY_URL:${{ needs.pre-setup.outputs.container-version - }}-$PLATFORM; - docker tag $IMAGE_ID $PLATFORM_CONTAINER_URL - && - docker push $PLATFORM_CONTAINER_URL - - # ghcr-manifest: - # name: 🐳 → GHCR cross-platform manifest - # runs-on: Ubuntu-latest - # needs: - # - docker - # - pre-setup # transitive, for accessing settings - # steps: - # - name: Login to GHCR - # uses: docker/login-action@v1 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - # - name: Create & Push manifest - # run: >- - # REGISTRY_URL="ghcr.io/abhinavsingh/proxy.py"; - # docker run --rm $REGISTRY_URL - # REGISTRY_TAG=$REGISTRY_URL:${{ - # needs.pre-setup.outputs.container-version - # }}; - # docker pull $REGISTRY_TAG-linux.386 && - # docker pull $REGISTRY_TAG-linux.arm.v6 && - # docker pull $REGISTRY_TAG-linux.arm.v7 && - # docker pull $REGISTRY_TAG-linux.arm64 && - # docker pull $REGISTRY_TAG-linux.arm64.v8 && - # docker pull $REGISTRY_TAG-linux.ppc64le && - # docker pull $REGISTRY_TAG-linux.s390x && - # docker manifest create - # $REGISTRY_TAG - # $REGISTRY_TAG-linux.386 - # $REGISTRY_TAG-linux.amd64 - # $REGISTRY_TAG-linux.arm.v6 - # $REGISTRY_TAG-linux.arm.v7 - # $REGISTRY_TAG-linux.arm64.v8 - # $REGISTRY_TAG-linux.ppc64le - # $REGISTRY_TAG-linux.s390x - # && - # docker manifest push $REGISTRY_TAG + }}; + LATEST_TAG=$REGISTRY_URL:latest; + docker buildx build + --push + --platform + linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + --build-arg PROXYPY_PKG_PATH='dist/${{ + needs.pre-setup.outputs.wheel-artifact-name + }}' + -t $CONTAINER_TAG + -t $LATEST_TAG . check: # This job does nothing and is only used for the branch protection if: always() diff --git a/Dockerfile b/Dockerfile index 0d59cd5bf5..5c359e5720 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ LABEL com.abhinavsingh.name="abhinavsingh/proxy.py" \ 👷 \"Work\" acceptor & executor framework" \ com.abhinavsingh.url="https://github.com/abhinavsingh/proxy.py" \ com.abhinavsingh.vcs-url="https://github.com/abhinavsingh/proxy.py" \ - com.abhinavsingh.docker.cmd="docker run -it --rm -p 8899:8899 abhinavsingh/proxy.py" + com.abhinavsingh.docker.cmd="docker run -it --rm -p 8899:8899 abhinavsingh/proxy.py" \ + org.opencontainers.image.source="https://github.com/abhinavsingh/proxy.py" ENV PYTHONUNBUFFERED 1 ARG PROXYPY_PKG_PATH diff --git a/Makefile b/Makefile index 48944ab1c6..5da6167be9 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ endif .PHONY: all https-certificates sign-https-certificates ca-certificates .PHONY: lib-check lib-clean lib-test lib-package lib-coverage lib-lint lib-pytest .PHONY: lib-release-test lib-release lib-profile lib-doc -.PHONY: lib-dep lib-flake8 lib-mypy lib-speedscope +.PHONY: lib-dep lib-flake8 lib-mypy lib-speedscope container-buildx-all-platforms .PHONY: container container-run container-release container-build container-buildx .PHONY: devtools dashboard dashboard-clean @@ -195,5 +195,11 @@ container-buildx: -t $(PROXYPY_CONTAINER_TAG) \ --build-arg PROXYPY_PKG_PATH=$(PROXYPY_PKG_PATH) . +container-buildx-all-platforms: + docker buildx build \ + --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x \ + -t $(PROXYPY_CONTAINER_TAG) \ + --build-arg PROXYPY_PKG_PATH=$(PROXYPY_PKG_PATH) . + container-run: docker run -it -p 8899:8899 --rm $(PROXYPY_CONTAINER_TAG) diff --git a/README.md b/README.md index 69d423364a..992cde04f2 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,9 @@ - [Stable version](#stable-version-with-pip) - [Development version](#development-version-with-pip) - [Using Docker](#using-docker) - - [Stable version](#stable-version-from-docker-hub) - - [Development version](#build-development-version-locally) + - [Stable version from Docker Hub](#stable-version-from-docker-hub) + - [Development Version from GHCR](#development-version-from-ghcr) + - [Build container locally](#build-development-version-locally) - [Using HomeBrew](#using-homebrew) - [Stable version](#stable-version-with-homebrew) - [Development version](#development-version-with-homebrew) @@ -248,6 +249,15 @@ or from GitHub `master` branch ## Using Docker +Multi-platform containers are available via: + +- Docker Hub + - `latest` tag points to last `stable` release + - `docker pull abhinavsingh/proxy.py:latest` +- GitHub container registry (GHCR) + - `latest` tag points to last `develop` release + - `docker pull ghcr.io/abhinavsingh/proxy.py:latest` + Stable version container releases are available for following platforms: - `linux/386` @@ -266,12 +276,21 @@ Run `proxy.py` latest container: ❯ docker run -it -p 8899:8899 --rm abhinavsingh/proxy.py:latest ``` +Docker daemon will automatically pull the matching platform image. To run specific target platform container on multi-platform supported servers: ```console ❯ docker run -it -p 8899:8899 --rm --platform linux/arm64/v8 abhinavsingh/proxy.py:latest ``` +### Development Version from GHCR + +Run `proxy.py` container from cutting edge code in the develop branch: + +```console +❯ docker run -it -p 8899:8899 --rm ghcr.io/abhinavsingh/proxy.py:latest +``` + ### Build Development Version Locally ```console @@ -1690,7 +1709,7 @@ Now point your CDT instance to `ws://localhost:8899/devtools`. ## Stable vs Develop -- `master` branch contains latest `stable` code and is available via `PyPi` repository and `Docker` containers via `hub.docker.com` +- `master` branch contains latest `stable` code and is available via `PyPi` repository and `Docker` containers via `docker.io` and `ghcr.io` registries. Issues reported for `stable` releases are considered with top-priority. However, currently we don't back port fixes into older releases. Example, if you reported an issue in `v2.3.1`, but current `master` branch now contains `v2.4.0rc1`. Then, the fix will land in `v2.4.0rc2`.