|
1 | | -# |
2 | 1 | name: Create and publish client docker image |
3 | 2 |
|
4 | 3 | on: |
5 | 4 | workflow_dispatch: |
6 | 5 |
|
7 | | - |
8 | | - |
9 | | -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. |
10 | 6 | env: |
11 | 7 | REGISTRY: ghcr.io |
12 | | - IMAGE_NAME: ${{ github.repository }} |
| 8 | + IMAGE_NAME: northeastern-electric-racing/argos-client |
13 | 9 |
|
14 | | -# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. |
15 | 10 | jobs: |
16 | | - build-and-push-image: |
17 | | - runs-on: ubuntu-latest |
18 | | - # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. |
| 11 | + build-and-push: |
| 12 | + runs-on: ubuntu-24.04 |
19 | 13 | permissions: |
20 | 14 | contents: read |
21 | 15 | packages: write |
22 | | - # |
| 16 | + defaults: |
| 17 | + run: |
| 18 | + working-directory: ./angular-client |
23 | 19 | steps: |
24 | | - - name: Set up Docker Buildx |
25 | | - uses: docker/setup-buildx-action@v4.0.0 |
26 | | - - name: Checkout repository |
27 | | - uses: actions/checkout@v6 |
28 | | - # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. |
29 | | - - name: Log in to the Container registry |
30 | | - uses: docker/login-action@v4.0.0 |
| 20 | + - uses: actions/checkout@v6 |
| 21 | + |
| 22 | + - uses: actions/setup-node@v6 |
| 23 | + with: |
| 24 | + node-version: 20.17.0 |
| 25 | + |
| 26 | + - name: Install deps |
| 27 | + run: npm ci |
| 28 | + |
| 29 | + - name: Build production bundle |
| 30 | + run: npm run build:production |
| 31 | + |
| 32 | + # Stage dist where Dockerfile.prebuilt expects it; /dist is in .dockerignore, |
| 33 | + # so the docker context can't pull from dist/angular-client/browser directly. |
| 34 | + - name: Stage dist into docker context |
| 35 | + run: cp -r dist/angular-client/browser browser |
| 36 | + |
| 37 | + - uses: docker/setup-qemu-action@v3 |
| 38 | + with: |
| 39 | + platforms: arm64 |
| 40 | + |
| 41 | + - uses: docker/setup-buildx-action@v4.0.0 |
| 42 | + |
| 43 | + - uses: docker/login-action@v4.0.0 |
31 | 44 | with: |
32 | 45 | registry: ${{ env.REGISTRY }} |
33 | 46 | username: ${{ github.actor }} |
34 | 47 | password: ${{ secrets.GITHUB_TOKEN }} |
35 | | - # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. |
36 | | - - name: Extract metadata (tags, labels) for Docker |
37 | | - id: meta |
38 | | - uses: docker/metadata-action@v6.0.0 |
39 | | - with: |
40 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-client |
41 | | - # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. |
42 | | - # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. |
43 | | - # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. |
44 | | - - name: Build and push Docker image for angular client |
45 | | - uses: docker/build-push-action@v7.0.0 |
| 48 | + |
| 49 | + # Multi-arch in one buildx push — apk add gettext is the only RUN, fine under QEMU. |
| 50 | + # All real CPU work (ng build) ran natively above; arch-sensitive part is just the nginx base layer. |
| 51 | + - uses: docker/build-push-action@v7.0.0 |
46 | 52 | with: |
47 | 53 | context: ./angular-client |
| 54 | + file: ./angular-client/Dockerfile.prebuilt |
48 | 55 | push: true |
49 | | - target: production |
50 | | - platforms: linux/arm64,linux/amd64 |
51 | | - tags: ${{ steps.meta.outputs.tags }} |
52 | | - labels: ${{ steps.meta.outputs.labels }} |
53 | | - # for caching |
54 | | - # cache-from: type=gha,scope=global |
55 | | - # cache-to: type=gha,mode=max,scope=global |
56 | | - # https://github.com/docker/build-push-action/issues/820 |
| 56 | + platforms: linux/amd64,linux/arm64 |
| 57 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} |
57 | 58 | provenance: false |
58 | | - build-args: | |
59 | | - PROD=true |
0 commit comments