Skip to content

Commit

Permalink
Cross-platform build (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostpoint-ru authored Jul 10, 2024
1 parent 0863aa8 commit 38edd0f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 25 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,46 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Extract branch variable
- name: Extract branch variable
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
-
name: Extract revision variable

- name: Extract revision variable
run: echo "GIT_REVISION=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GHCR as ${{ github.actor }}

- name: Login to GHCR as ${{ github.actor }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push

# Required to mount the Github Workspace to a volume
- name: Checkout
uses: actions/checkout@v4

- name: Build static content
uses: addnab/docker-run-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
image: ghcr.io/wirenboard/website-base-image:initial
options: -v ${{ github.workspace }}:/var/www
run: |
cd /var/www
pnpm install
pnpm run build
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,arm64
tags: |
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/ci-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,29 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
# Required to mount the Github Workspace to a volume
- name: Checkout
uses: actions/checkout@v4

- name: Build static content
uses: addnab/docker-run-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
image: ghcr.io/wirenboard/website-base-image:initial
options: -v ${{ github.workspace }}:/var/www
run: |
cd /var/www
pnpm install
pnpm run build
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
platforms: linux/amd64,arm64
tags: |
ghcr.io/wirenboard/website:${{ env.BRANCH }}-${{ env.GIT_REVISION }}
ghcr.io/wirenboard/website:${{ env.BRANCH }}
Expand Down
15 changes: 4 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
FROM ghcr.io/wirenboard/website-base-image:initial as builder

WORKDIR /var/www

COPY . /var/www

RUN pnpm install

RUN pnpm run build

FROM nginx

COPY --from=builder /var/www/.output/public/ /usr/share/nginx/html/
# Not really useful outside GitHub Actions - actual builds happens there,
# Dockerfile just copies the output to various flavors of Nginx image

COPY .output/public/ /usr/share/nginx/html/

0 comments on commit 38edd0f

Please sign in to comment.