|
| 1 | +name: development |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - '*' # matches every branch that doesn't contain a '/' |
| 8 | + - '*/*' # matches every branch containing a single '/' |
| 9 | + - '*/*/*' # matches every branch contains two / |
| 10 | + - '**' # matches every branch |
| 11 | + - '!main' # excludes main |
| 12 | + - '!master' # excludes master |
| 13 | + |
| 14 | + |
| 15 | +env: |
| 16 | + TARGET_PLATFORMS: linux/amd64,linux/arm64/v8 |
| 17 | + |
| 18 | +jobs: |
| 19 | + docker: |
| 20 | + strategy: |
| 21 | + fail-fast: true |
| 22 | + matrix: |
| 23 | + repository: |
| 24 | + - 'localhost:5000' |
| 25 | + python: |
| 26 | + - '3.14' |
| 27 | + - '3.13' |
| 28 | + - '3.12' |
| 29 | + - '3.11' |
| 30 | + - '3.10' |
| 31 | + - '3.9' |
| 32 | + - '3.8' |
| 33 | + alpine: |
| 34 | + - '3.20' |
| 35 | + - '3.21' |
| 36 | + - '3.22' |
| 37 | + os: |
| 38 | + - 'ubuntu-latest' |
| 39 | + exclude: |
| 40 | + # No tag |
| 41 | + - python: '3.8' |
| 42 | + alpine: '3.21' |
| 43 | + - python: '3.8' |
| 44 | + alpine: '3.22' |
| 45 | + - python: '3.14' |
| 46 | + alpine: '3.20' |
| 47 | + |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + services: |
| 50 | + registry: |
| 51 | + image: registry:3 |
| 52 | + ports: |
| 53 | + - 5000:5000 |
| 54 | + |
| 55 | + permissions: |
| 56 | + packages: write |
| 57 | + |
| 58 | + steps: |
| 59 | + - |
| 60 | + name: Checkout |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - |
| 64 | + name: Set up QEMU |
| 65 | + uses: docker/setup-qemu-action@v3 |
| 66 | + - |
| 67 | + name: Set up Docker Buildx |
| 68 | + uses: docker/setup-buildx-action@v3 |
| 69 | + |
| 70 | + - |
| 71 | + id: image_env |
| 72 | + run: | |
| 73 | + . ./env.sh \ |
| 74 | + '${{ matrix.alpine }}' \ |
| 75 | + '${{ matrix.python }}' \ |
| 76 | + '${{ github.repository_owner }}' \ |
| 77 | + '${{ matrix.repository }}' |
| 78 | +
|
| 79 | + docker pull "${SOURCE_IMAGE}" || true |
| 80 | + echo "IMAGE_HOME=$(mktemp -d)" >> "$GITHUB_OUTPUT" |
| 81 | +
|
| 82 | + echo ALPINE_VERSION="${ALPINE_VERSION}" >> "$GITHUB_OUTPUT" |
| 83 | + echo PYTHON_VERSION="${PYTHON_VERSION}" >> "$GITHUB_OUTPUT" |
| 84 | + echo SOURCE_IMAGE="${SOURCE_IMAGE}" >> "$GITHUB_OUTPUT" |
| 85 | + echo IMAGE_TAG="${IMAGE_TAG}" >> "$GITHUB_OUTPUT" |
| 86 | + echo REPOSITORY="${REPOSITORY}" >> "$GITHUB_OUTPUT" |
| 87 | + echo BASE_IMAGE_DIGEST="$(digest_of "$SOURCE_IMAGE")" >> "$GITHUB_OUTPUT" |
| 88 | + echo 'IMAGE_DESCRIPTION=${{ github.event.repository.description }}. See ${{ github.server_url }}/${{ github.repository }} for more info.' >> "$GITHUB_OUTPUT" |
| 89 | + - |
| 90 | + name: Create Buildroot |
| 91 | + uses: docker/build-push-action@v6 |
| 92 | + with: |
| 93 | + push: true |
| 94 | + platforms: ${{ env.TARGET_PLATFORMS }} |
| 95 | + context: "." |
| 96 | + file: Dockerfile.alpine |
| 97 | + target: buildroot |
| 98 | + cache-to: | |
| 99 | + type=gha,mode=max |
| 100 | + cache-from: | |
| 101 | + type=gha |
| 102 | + type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot |
| 103 | + type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} |
| 104 | + build-args: | |
| 105 | + ALPINE_VERSION=${{ steps.image_env.outputs.ALPINE_VERSION }} |
| 106 | + BASE_IMAGE_DIGEST=${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} |
| 107 | + PYTHON_VERSION=${{ steps.image_env.outputs.PYTHON_VERSION }} |
| 108 | + SOURCE_IMAGE=${{ steps.image_env.outputs.SOURCE_IMAGE }} |
| 109 | + BUILD_ROOT=/d |
| 110 | + tags: "${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot" |
| 111 | + - |
| 112 | + name: Create Image |
| 113 | + uses: docker/build-push-action@v6 |
| 114 | + env: |
| 115 | + SOURCE_DATE_EPOCH: 0 |
| 116 | + with: |
| 117 | + push: true |
| 118 | + context: "." |
| 119 | + platforms: ${{ env.TARGET_PLATFORMS }} |
| 120 | + file: Dockerfile.alpine |
| 121 | + cache-to: | |
| 122 | + type=gha,mode=max |
| 123 | + cache-from: | |
| 124 | + type=gha |
| 125 | + type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }} |
| 126 | + type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot |
| 127 | + type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} |
| 128 | + build-args: | |
| 129 | + ALPINE_VERSION=${{ steps.image_env.outputs.ALPINE_VERSION }} |
| 130 | + BASE_IMAGE_DIGEST=${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} |
| 131 | + PYTHON_VERSION=${{ steps.image_env.outputs.PYTHON_VERSION }} |
| 132 | + SOURCE_IMAGE=${{ steps.image_env.outputs.SOURCE_IMAGE }} |
| 133 | + BUILD_ROOT=/d |
| 134 | + tags: "${{ steps.image_env.outputs.IMAGE_TAG }}" |
| 135 | + labels: ${{steps.image_env.outputs.IMAGE_LABELS}} |
| 136 | + sbom: true |
| 137 | + annotations: | |
| 138 | + index,manifest:org.opencontainers.image.authors=distroless-python image developers <autumn.jolitz+distroless-python@gmail.com> |
| 139 | + index,manifest:org.opencontainers.image.source=https://github.com/autumnjolitz/distroless-python |
| 140 | + index,manifest:org.opencontainers.image.title=distroless-python${{ steps.image_env.outputs.PYTHON_VERSION }}-alpine${{ steps.image_env.outputs.ALPINE_VERSION }} |
| 141 | + index,manifest:org.opencontainers.image.description=${{ steps.image_env.outputs.IMAGE_DESCRIPTION }} |
| 142 | + index,manifest:org.opencontainers.image.base.digest=${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} |
| 143 | + index,manifest:org.opencontainers.image.base.name=${{ steps.image_env.outputs.SOURCE_IMAGE }} |
| 144 | + index,manifest:distroless.python-version=${{ steps.image_env.outputs.PYTHON_VERSION }} |
| 145 | + index,manifest:distroless.alpine-version=${{ steps.image_env.outputs.ALPINE_VERSION }} |
| 146 | + index,manifest:distroless.base-image=alpine${{ steps.image_env.outputs.ALPINE_VERSION }} |
| 147 | +
|
| 148 | + - |
| 149 | + name: examples/simple-flask |
| 150 | + uses: docker/build-push-action@v6 |
| 151 | + with: |
| 152 | + context: "examples/simple-flask" |
| 153 | + platforms: ${{ env.TARGET_PLATFORMS }} |
| 154 | + cache-from: | |
| 155 | + type=gha |
| 156 | + type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }} |
| 157 | + type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot |
| 158 | + type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} |
| 159 | + build-args: | |
| 160 | + SOURCE_IMAGE=${{ steps.image_env.outputs.IMAGE_TAG }} |
| 161 | + tags: "${{ steps.image_env.outputs.IMAGE_TAG }}-example1-amd64" |
| 162 | + outputs: type=oci,dest=${{ steps.image_env.outputs.IMAGE_HOME }}/example1.tar |
| 163 | + |
| 164 | + |
| 165 | + render-dockerhub-desc: |
| 166 | + needs: [docker] |
| 167 | + runs-on: "ubuntu-latest" |
| 168 | + steps: |
| 169 | + - |
| 170 | + name: Checkout |
| 171 | + uses: actions/checkout@v4 |
| 172 | + - |
| 173 | + name: Convert README.rst to markdown |
| 174 | + uses: docker://pandoc/core:2.9 |
| 175 | + with: |
| 176 | + args: >- |
| 177 | + -s |
| 178 | + --wrap=none |
| 179 | + -t gfm |
| 180 | + -o README.md |
| 181 | + README.rst |
0 commit comments