From f031bd1361983c2605d62c2adba858e83038e2a1 Mon Sep 17 00:00:00 2001 From: Doh Date: Fri, 3 Jan 2025 21:02:27 -0500 Subject: [PATCH] build arm image (#12) --- .github/workflows/docker-publish.yml | 29 +++-- .github/workflows/test.yml | 25 ++++ Dockerfile | 6 +- package-lock.json | 166 +++++++++++++++++++++++++++ package.json | 2 +- 5 files changed, 208 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 1ec2608..f656d42 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -4,7 +4,7 @@ on: push: branches: - main - # - github-actions + - github-actions jobs: build-and-push: @@ -40,22 +40,19 @@ jobs: echo "EXISTS=false" >> $GITHUB_OUTPUT fi - - name: Build Docker image - run: docker build -t habittrove . + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Push Docker images - run: | - if [ "${{ steps.check-version.outputs.EXISTS }}" = "false" ]; then - docker tag habittrove dohsimpson/habittrove:v${{ steps.package-version.outputs.VERSION }} - docker push dohsimpson/habittrove:v${{ steps.package-version.outputs.VERSION }} - echo "Pushed tag: v${{ steps.package-version.outputs.VERSION }}" - docker tag habittrove dohsimpson/habittrove:latest - docker push dohsimpson/habittrove:latest - echo "Pushed tag: latest" - fi - docker tag habittrove dohsimpson/habittrove:dev - docker push dohsimpson/habittrove:dev - echo "Pushed tag: dev" + - name: Build and push Docker images + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ steps.check-version.outputs.EXISTS == 'false' && format('dohsimpson/habittrove:v{0}', steps.package-version.outputs.VERSION) || '' }} + ${{ steps.check-version.outputs.EXISTS == 'false' && 'dohsimpson/habittrove:latest' || '' }} + dohsimpson/habittrove:dev deploy-demo: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2b02a89 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Unit Tests + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Run unit tests + run: bun test diff --git a/Dockerfile b/Dockerfile index afe8e5e..f19cb26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ # syntax=docker.io/docker/dockerfile:1 -FROM node:18-alpine AS base +FROM --platform=$BUILDPLATFORM node:18-alpine AS base # Install dependencies only when needed -FROM base AS deps +FROM --platform=$BUILDPLATFORM base AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app @@ -19,7 +19,7 @@ RUN \ fi # Rebuild the source code only when needed -FROM base AS builder +FROM --platform=$BUILDPLATFORM base AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . diff --git a/package-lock.json b/package-lock.json index dd72af6..ef6a596 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@types/bun": "^1.1.14", "@types/canvas-confetti": "^1.9.0", "@uiw/react-heat-map": "^2.3.2", + "bun": "^1.1.42", "canvas-confetti": "^1.9.3", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", @@ -892,6 +893,138 @@ "node": ">=12.4.0" } }, + "node_modules/@oven/bun-darwin-aarch64": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.1.42.tgz", + "integrity": "sha512-7kQkTVr99ndcU72xlIzA2QLavvT/DnEhvwTAq7LKi9/P3GtSAkhoA6UWZUa7pYw7OYHpUrEGXlV+PR3LllkGnw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-darwin-x64": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.1.42.tgz", + "integrity": "sha512-2IPJnLvwLlD8YaXPbWwlpw2UvVrZE6/0uRbcSJNzZQAAZjEfN8AodqNRhggptn0A9vDmAw6q1U07QbiE4ilofw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-darwin-x64-baseline": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.1.42.tgz", + "integrity": "sha512-26mtzVRLp/x89s27fXExG1vCCBOOFHLdqVYg/lHZMdDNHSh7Q7UiUhDRa+aVBlbsaGfw1LzoXdhh7Zy2hlF/6w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-linux-aarch64": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.1.42.tgz", + "integrity": "sha512-qkoqI+oMcQ8GUej71qkAVj/VLlVpoBRyiYBQYq4yWsy+FU2jr2KWTeNZWrsY2crDiZj38AMNXJiKBr/EMy4MRg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-aarch64-musl": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.1.42.tgz", + "integrity": "sha512-PwbNLoirazjTYTSydn2AnId0jBJexZ99cwftOfdzIGCF5anEWvNEZ8PL4o79jHIhE0t01qGc8br9fQbiQ+iArw==", + "cpu": [ + "aarch64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.1.42.tgz", + "integrity": "sha512-rV8Eqnvo/1z0nwYSiLrbl0F4G8uFQxlGA4P0zggW9W4PSiSHSRhG1aazG/8esBLzJI9CdFNncrtmiRTmWl1mIg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64-baseline": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.1.42.tgz", + "integrity": "sha512-UzRNXgHEARFECgz30eot23OnPzd0J2L5SEsGhnGRhfJ706kjz0XmuGMnb9nmnoyHBcd2iSjk4nci1BlGmu4wCA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64-musl": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.1.42.tgz", + "integrity": "sha512-Djye8lPlhVNXdGbMF4bShVop8qvqPhPuPrhxEHfYJ8qhudSs2MiOWR5stvBWe8KLKahqDAWfWXuxByAXVhqb2Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64-musl-baseline": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.1.42.tgz", + "integrity": "sha512-zgeiYJRGO3K4uK6Qdj1B5ZbU9NJxLwF9YGDFu9MtqEplyGNq7SpeuamvcP6SlZGgrVnc3AWrHFEYrVlv5Lqt+w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-windows-x64": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.1.42.tgz", + "integrity": "sha512-6eyHs6fVRCy0ujltYTwSX3bug+PqlgZRBv8x0PPekviaCJWYrFKVpHodA2972+Mih2pATurBSX2sLVq5uJUU7Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oven/bun-windows-x64-baseline": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.1.42.tgz", + "integrity": "sha512-xnlYa1jKknImCw7xmSD91H8e+w3BC6mIShOfHhFWfNhdyvEtundXhIu7VddwxKBMs5S/iiFJiutnZ2EyLq4CAQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -2618,6 +2751,39 @@ "dev": true, "peer": true }, + "node_modules/bun": { + "version": "1.1.42", + "resolved": "https://registry.npmjs.org/bun/-/bun-1.1.42.tgz", + "integrity": "sha512-PckeNolMEBaBEzixTMvp0jJD9r/9lly8AfctILi1ve14zwwChFjsxI4TJLQO2yezzOjVeG0u7xf8WQFbS7GjAA==", + "cpu": [ + "arm64", + "x64", + "aarch64" + ], + "hasInstallScript": true, + "os": [ + "darwin", + "linux", + "win32" + ], + "bin": { + "bun": "bin/bun.exe", + "bunx": "bin/bun.exe" + }, + "optionalDependencies": { + "@oven/bun-darwin-aarch64": "1.1.42", + "@oven/bun-darwin-x64": "1.1.42", + "@oven/bun-darwin-x64-baseline": "1.1.42", + "@oven/bun-linux-aarch64": "1.1.42", + "@oven/bun-linux-aarch64-musl": "1.1.42", + "@oven/bun-linux-x64": "1.1.42", + "@oven/bun-linux-x64-baseline": "1.1.42", + "@oven/bun-linux-x64-musl": "1.1.42", + "@oven/bun-linux-x64-musl-baseline": "1.1.42", + "@oven/bun-windows-x64": "1.1.42", + "@oven/bun-windows-x64-baseline": "1.1.42" + } + }, "node_modules/bun-types": { "version": "1.1.37", "resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.1.37.tgz", diff --git a/package.json b/package.json index b21fe5e..1085d5b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "@radix-ui/react-slot": "^1.1.1", "@radix-ui/react-switch": "^1.1.2", "@radix-ui/react-toast": "^1.2.4", - "@types/bun": "^1.1.14", "@types/canvas-confetti": "^1.9.0", "@uiw/react-heat-map": "^2.3.2", "canvas-confetti": "^1.9.3", @@ -47,6 +46,7 @@ "@types/node": "^20.17.10", "@types/react": "^19", "@types/react-dom": "^19", + "@types/bun": "^1.1.14", "eslint": "^9", "eslint-config-next": "15.1.3", "eslint-plugin-unused-imports": "^4.1.4",