Просмотр исходного кода

Add multi-platform build support for linux/arm64 (#32)

* Add multi-platform build support for linux/arm64

* Update README and simplify QEMU platforms

* Update frontend dependencies and clippy lints (#33)

* Only build ARM64 images on pushes to main
Eric Zhang 3 лет назад
Родитель
Сommit
2caf088167
3 измененных файлов с 10 добавлено и 6 удалено
  1. 4 0
      .github/workflows/ci.yml
  2. 2 2
      Dockerfile
  3. 4 4
      README.md

+ 4 - 0
.github/workflows/ci.yml

@@ -18,6 +18,8 @@ jobs:
 
       - name: Set up QEMU
         uses: docker/setup-qemu-action@v1
+        with:
+          platforms: arm64
 
       - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v1
@@ -32,6 +34,8 @@ jobs:
         id: docker_build
         uses: docker/build-push-action@v2
         with:
+          platforms: |
+            ${{ github.event_name == 'push' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
           push: ${{ github.event_name == 'push' }}
           build-args: GITHUB_SHA
           tags: ekzhang/rustpad:latest

+ 2 - 2
Dockerfile

@@ -5,14 +5,14 @@ COPY . .
 RUN cargo test --release
 RUN cargo build --release
 
-FROM rust:alpine as wasm
+FROM amd64/rust:alpine as wasm
 WORKDIR /home/rust/src
 RUN apk --no-cache add curl musl-dev
 RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
 COPY . .
 RUN wasm-pack build --target web rustpad-wasm
 
-FROM node:lts-alpine as frontend
+FROM amd64/node:lts-alpine as frontend
 WORKDIR /usr/src/app
 COPY package.json package-lock.json ./
 COPY --from=wasm /home/rust/src/rustpad-wasm/pkg rustpad-wasm/pkg

+ 4 - 4
README.md

@@ -96,16 +96,16 @@ following environment variables on startup:
 
 Rustpad is distributed as a single 6 MB Docker image, which is built
 automatically from the `Dockerfile` in this repository. You can pull the latest
-version of this image from Docker Hub.
+version of this image from Docker Hub. It has multi-platform support for
+`linux/amd64` and `linux/arm64`.
 
 ```
 docker pull ekzhang/rustpad
 ```
 
 (You can also manually build this image with `docker build -t rustpad .` in the
-project root directory, ensuring that your target platform is `linux/amd64`.) To
-run locally, execute the following command, then open `http://localhost:3030` in
-your browser.
+project root directory.) To run locally, execute the following command, then
+open `http://localhost:3030` in your browser.
 
 ```
 docker run --rm -dp 3030:3030 ekzhang/rustpad