diff --git a/.dockerignore b/.dockerignore index 6ef1e2ac4..a12800b69 100644 --- a/.dockerignore +++ b/.dockerignore @@ -34,5 +34,4 @@ cache .github .husky .parcel-cache -.scripts .vscode diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f3d035762..df43b7c90 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,9 +36,6 @@ jobs: type=raw,enable=${{ startsWith(github.ref, 'refs/tags/v') }},value=prerelease type=edge - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub uses: docker/login-action@v2 with: @@ -52,9 +49,14 @@ jobs: username: silverhand-bot password: ${{ secrets.BOT_PAT }} - - name: Build and push - uses: docker/build-push-action@v4 + - name: Setup Depot + uses: depot/setup-action@v1 + + - name: Build + uses: depot/build-push-action@v1 with: + platforms: linux/amd64, linux/arm64 + project: g902cp6dvv context: . push: true tags: ${{ steps.meta.outputs.tags }} diff --git a/.scripts/update-parcelrc.js b/.scripts/update-parcelrc.js new file mode 100644 index 000000000..7258a3691 --- /dev/null +++ b/.scripts/update-parcelrc.js @@ -0,0 +1,23 @@ +import { execSync } from 'child_process'; +import path from 'path'; +import fs from 'fs/promises'; + +if (!process.arch.startsWith('arm')) { + process.exit(0); +} + +execSync('rm packages/**/.parcelrc'); + +const updateParcelRcArm64 = async (dir) => { + const dirents = await fs.readdir(dir, { withFileTypes: true }); + + for (const dirent of dirents) { + if (dirent.isDirectory()) { + await updateParcelRcArm64(path.resolve(dir, dirent.name)); + } else if (dirent.name === '.parcelrc.arm64') { + await fs.rename(path.resolve(dir, dirent.name), path.resolve(dir, '.parcelrc')); + } + } +}; + +await updateParcelRcArm64(path.resolve('packages')); diff --git a/Dockerfile b/Dockerfile index b7ca53e09..5ce463653 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN apk add --no-cache python3 make g++ COPY . . # Install dependencies and build +RUN node .scripts/update-parcelrc.js RUN pnpm i RUN pnpm -r build @@ -25,7 +26,7 @@ RUN rm -rf node_modules packages/**/node_modules RUN NODE_ENV=production pnpm i # Clean up -RUN rm -rf .parcel-cache pnpm-*.yaml +RUN rm -rf .scripts .parcel-cache pnpm-*.yaml # Seal stage FROM node:18-alpine as app diff --git a/packages/console/.parcelrc.arm64 b/packages/console/.parcelrc.arm64 new file mode 100644 index 000000000..5837881e6 --- /dev/null +++ b/packages/console/.parcelrc.arm64 @@ -0,0 +1,12 @@ +{ + "extends": "@parcel/config-default", + "optimizers": { + // Disable optimizers in arm64 arch https://github.com/parcel-bundler/parcel/issues/7402 + "*.{jpg,jpeg,png}": [] + }, + "transformers": { + "**/assets/images/*.svg": [ + "@parcel/transformer-svg-react" + ] + } +} diff --git a/packages/demo-app/.parcelrc.arm64 b/packages/demo-app/.parcelrc.arm64 new file mode 100644 index 000000000..0c8337cd8 --- /dev/null +++ b/packages/demo-app/.parcelrc.arm64 @@ -0,0 +1,7 @@ +{ + "extends": "@parcel/config-default", + "optimizers": { + // Disable optimizers in arm64 arch https://github.com/parcel-bundler/parcel/issues/7402 + "*.{jpg,jpeg,png}": [] + } +} diff --git a/packages/ui/.parcelrc.arm64 b/packages/ui/.parcelrc.arm64 new file mode 100644 index 000000000..1d2db2238 --- /dev/null +++ b/packages/ui/.parcelrc.arm64 @@ -0,0 +1,12 @@ +{ + "extends": "@parcel/config-default", + "optimizers": { + // Disable optimizers in arm64 arch https://github.com/parcel-bundler/parcel/issues/7402 + "*.{jpg,jpeg,png}": [] + }, + "transformers": { + "**/assets/icons/*.svg": [ + "@parcel/transformer-svg-react" + ] + } +}