diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index 2f7ce05..e3a81d5 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -6,8 +6,44 @@ on: - main jobs: + build_docker_image_track_base_client_builder: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Paths Changes Filter + uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + lock: + - 'web-client/Dockerfile.base-builder' + + - name: Authenticate with GCP service account + if: steps.changes.outputs.lock == 'true' + uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GCP_SA_KEY }} + + - name: Set up Cloud SDK + if: steps.changes.outputs.lock == 'true' + uses: google-github-actions/setup-gcloud@v1 + + - name: Configure Docker to use Google Artifact Registry + if: steps.changes.outputs.lock == 'true' + run: gcloud auth configure-docker us-central1-docker.pkg.dev + + - name: Build Base Builder Image + if: steps.changes.outputs.lock == 'true' + run: | + docker build -f web-client/Dockerfile.base-builder --target base-builder -t us-central1-docker.pkg.dev/hubs-dev-333333/ocho-osai/johnshaughnessy/track/track-client-base-builder . + docker push us-central1-docker.pkg.dev/hubs-dev-333333/ocho-osai/johnshaughnessy/track/track-client-base-builder + build_docker_image_track_client_builder: runs-on: ubuntu-latest + needs: build_docker_image_track_base_client_builder steps: - name: Checkout code @@ -21,8 +57,9 @@ jobs: lock: - 'web-client/Cargo.lock' - 'web-client/Dockerfile.builder' + - 'web-client/Dockerfile.base-builder' - - id: auth + - name: Authenticate with GCP service account if: steps.changes.outputs.lock == 'true' uses: google-github-actions/auth@v1 with: @@ -77,4 +114,4 @@ jobs: uses: google-github-actions/upload-cloud-storage@v1 with: path: "web-client-${{ env.SHORT_SHA }}.tar.gz" - destination: "gs://ocho-osai/track/web-client-builds/web-client-${{ env.SHORT_SHA }}.tar.gz" + destination: "ocho-osai/track/web-client-builds/" diff --git a/.github/workflows/deploy-client.yml b/.github/workflows/deploy-client.yml index b07e41e..2a67cad 100644 --- a/.github/workflows/deploy-client.yml +++ b/.github/workflows/deploy-client.yml @@ -26,6 +26,7 @@ jobs: deploy_static_files: needs: validate runs-on: ubuntu-latest + environment: ${{ github.event.inputs.env }} steps: - name: Authenticate with GCP uses: google-github-actions/auth@v1 @@ -40,6 +41,12 @@ jobs: - name: Determine latest web-client tarball id: latest-tarball run: | + + # Authenticate with GCP + echo '${{ secrets.GCP_SA_KEY }}' > /tmp/gcp-sa-key.json + gcloud auth activate-service-account --key-file=/tmp/gcp-sa-key.json + rm /tmp/gcp-sa-key.json $BACKUP_NAME + LATEST_TARBALL=$(gsutil ls gs://ocho-osai/track/web-client-builds/ | sort | tail -n1) echo "Latest tarball: $LATEST_TARBALL" echo "::set-output name=tarball::$LATEST_TARBALL" diff --git a/web-client/Dockerfile.base-builder b/web-client/Dockerfile.base-builder new file mode 100644 index 0000000..8159c96 --- /dev/null +++ b/web-client/Dockerfile.base-builder @@ -0,0 +1,5 @@ +FROM rust:1.73-slim-buster as base-builder +RUN rustup target add wasm32-unknown-unknown +RUN cargo install trunk +# Upload this image as track-client-base-builder +# rebuild=2 diff --git a/web-client/Dockerfile.builder b/web-client/Dockerfile.builder index 270fe41..d8ad450 100644 --- a/web-client/Dockerfile.builder +++ b/web-client/Dockerfile.builder @@ -1,10 +1,10 @@ -FROM rust:1.73-slim-buster as builder -RUN rustup target add wasm32-unknown-unknown -RUN cargo install trunk -COPY . . +# The base builder will have trunk installed +FROM us-central1-docker.pkg.dev/hubs-dev-333333/ocho-osai/johnshaughnessy/track/track-client-base-builder as builder WORKDIR /track +COPY . . +RUN ls -la +RUN ls -la web-client/ RUN trunk build web-client/index.html # Build once so that dependencies are cached RUN rm -rf web-client/dist # The built files are not needed in the final image -# Changes to this file will cause the workflow to rebuild the builder image -# Rebuild=1 +# Upload this image as track-client-builder