Switch to GHA and GHCR for image building and hosting #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Georust Docker Images | |
on: | |
push: | |
branches: | |
- main | |
- staging | |
- trying | |
pull_request: | |
merge_group: | |
env: | |
LIBPROJ_VERSION: 9.4.0 | |
BASE_IMAGE_NAME: libproj-builder | |
jobs: | |
build_base_image: | |
name: Build the base image for geo and proj | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
rust_version: [1.77] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Up Builder | |
run: | | |
docker buildx create --name mybuilder | |
docker buildx use mybuilder | |
docker buildx inspect --bootstrap | |
- name: Build and export base image to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ env.BASE_IMAGE_NAME }} | |
push: false | |
load: true | |
platforms: linux/amd64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ env.BASE_IMAGE_NAME }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} | |
- name: Test base image | |
run: | | |
# docker run --rm ghcr.io/${{ github.repository_owner }}/${{ env.BASE_IMAGE_NAME }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
- name: Push tested base image | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ env.BASE_IMAGE_NAME }} | |
push: true | |
load: false | |
# platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ env.BASE_IMAGE_NAME }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
outputs: type=docker,dest=/tmp/${{ env.BASE_IMAGE_NAME }}-proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }}.tar | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} | |
build_dependent_images: | |
name: Build dependent images for geo and proj | |
needs: build_base_image | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
docker_image_name: | |
- proj-ci | |
- proj-ci-without-system-proj | |
- geo-ci | |
rust_version: [1.77] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Up Builder | |
run: | | |
docker buildx create --name mybuilder | |
docker buildx use mybuilder | |
docker buildx inspect --bootstrap | |
- name: Build ${{ matrix.docker_image_name }} | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ matrix.docker_image_name }} | |
push: false | |
load: true | |
platforms: linux/amd64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_image_name }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} | |
- name: Set up test command for geo-ci | |
if: contains('geo', ${{ matrix.docker_image_name }}) | |
run: echo "RUN_CMD=git clone https://github.com/georust/geo.git && cd geo && cargo test --no-default-features && cargo test && cargo test --all-features" >> $GITHUB_ENV | |
- name: Set up test command for proj-ci-without-system-proj-ci | |
if: contains('system', ${{ matrix.docker_image_name }}) | |
run: echo "RUN_CMD=git clone https://github.com/georust/proj.git && cd proj && cargo test --features bundled_proj" >> $GITHUB_ENV | |
- name: Set up test command for proj-ci | |
if: ${{ matrix.docker_image_name }} == proj-ci | |
run: echo "RUN_CMD=git clone https://github.com/georust/proj.git && cd proj && cargo test --no-default-features && cargo test --features bundled_proj && cargo test --features network" >> $GITHUB_ENV | |
- name: Test ${{ matrix.docker_image_name }} | |
run: | | |
docker run --rm ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_image_name }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} /bin/bash -c "${{ env.RUN_CMD }}" | |
- name: Push tested ${{ matrix.docker_image_name }} image | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./dockerfiles/${{ matrix.docker_image_name }} | |
push: true | |
load: false | |
# platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_image_name }}:proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }} | |
outputs: type=docker,dest=/tmp/${{ matrix.docker_image_name }}-proj-${{ env.LIBPROJ_VERSION }}-rust-${{ matrix.rust_version }}.tar | |
build-args: | | |
RUST_VERSION=${{ matrix.rust_version }} | |
PROJ_VERSION=${{ env.LIBPROJ_VERSION }} |