|
1 | 1 | # Python Image Builder - Github Action |
| 2 | + |
| 3 | +This Github Action is part of the [Multi-Py Project](https://github.com/multi-py). It works alongside the [Multi-Py Python Versionator Action](https://github.com/multi-py/action-python-versionator) to continuously release multiarchitecture containers. |
| 4 | + |
| 5 | +The Image Builder is focused on building a single multiarchitecture image around a python package. It uses a two stage approach where the python packages are compiled in a base image and then moved to the final image. This allows for consistent builds and smaller output images. |
| 6 | + |
| 7 | +Using this action, the Github Action Matrix Strategy, and the Versionator allows for building a complex set of images with the most recent versions of the tracked packages. |
| 8 | + |
| 9 | +## Example |
| 10 | + |
| 11 | +```yaml |
| 12 | + |
| 13 | +name: Example Image Builder |
| 14 | + |
| 15 | +# Publish on new pushed, and build on Monday Morning (UTC) regardless. |
| 16 | +on: |
| 17 | + push: |
| 18 | + branches: |
| 19 | + - 'main' |
| 20 | + schedule: |
| 21 | + - cron: '4 0 * * MON' |
| 22 | + |
| 23 | +jobs: |
| 24 | + Uvicorn-Builder: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + python_version: ["3.6", "3.7", "3.8", "3.9", "3.10"] |
| 30 | + package_versions: ["0.12.1", "0.12.2", "0.12.3", "0.13.0", "0.13.1", "0.13.2", "0.13.3", "0.13.4", "0.14.0", "0.15.0"] |
| 31 | + target_base: ["full", "slim", "alpine"] |
| 32 | + steps: |
| 33 | + |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@v2 |
| 36 | + |
| 37 | + - name: "Create and push" |
| 38 | + uses: multi-py/action-python-image-builder@main |
| 39 | + with: |
| 40 | + package: "uvicorn" |
| 41 | + package_latest_version: "0.15.0" |
| 42 | + maintainer: "Myname <[email protected]>" |
| 43 | + python_version: ${{ matrix.python_version }} |
| 44 | + target_base: ${{ matrix.target_base }} |
| 45 | + package_version: ${{ matrix.package_versions }} |
| 46 | + registry_password: ${{ secrets.GITHUB_TOKEN }} |
| 47 | +``` |
| 48 | +
|
| 49 | +The `python_version`, `package_versions`, and `package_latest_version` values get updated by a separate Versionator action. |
| 50 | + |
| 51 | +This particular config supports five python versions, three variant images, ten package versions, and three architectures. This results in 150 high level images each consisting of three architectures, for a total of 450 builds across 150 workflows on each run. |
| 52 | + |
| 53 | +## Docker Files and Context |
| 54 | + |
| 55 | +By default this action uses its own dockerfile and repository as context. This can be overridden with the `dockerfile` and `docker_build_path` parameters. To get the most out of this action start with the dockerfile here and expand it so that build arguments will still work. |
0 commit comments