0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

ci: use depot to build docker image (#3116)

This commit is contained in:
Gao Sun 2023-02-15 17:02:59 +08:00 committed by GitHub
parent de0d22037d
commit 525bd403d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 7 deletions

View file

@ -34,5 +34,4 @@ cache
.github
.husky
.parcel-cache
.scripts
.vscode

View file

@ -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 }}

View file

@ -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'));

View file

@ -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

View file

@ -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"
]
}
}

View file

@ -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}": []
}
}

View file

@ -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"
]
}
}