Skip to content

Commit

Permalink
Merge pull request #3 from kankerdev/main
Browse files Browse the repository at this point in the history
Make CI build arm64 and amd64 image
  • Loading branch information
DaXcess authored Sep 25, 2023
2 parents 2131299 + d663c86 commit 75935cc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
50 changes: 40 additions & 10 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
name: Build and push to repository
name: Build and push to registry

on:
push:
branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
workflow_dispatch:

permissions:
packages: write
contents: read

jobs:
build-and-push:
name: Build Docker image and push to repository
name: Build Docker image and push to registry
runs-on: ubuntu-latest

steps:
Expand All @@ -17,17 +24,40 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v2

- name: Login to repository
- name: Login to GitHub's Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: Entepotenz/change-string-case-action-min-dependencies@v1 # https://github.com/orgs/community/discussions/10553
id: repo-uri-string
with:
string: ghcr.io/${{ github.repository }}

- name: Generate image metadata
id: spoticord-accounts # used in next step
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: ${{ steps.repo-uri-string.outputs.lowercase }}
# Docker tags based on the following events/attributes
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Build image and push to registry
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
tags: |
${{ secrets.REGISTRY_URL }}/spoticord/accounts:latest
push: ${{ github.ref == 'refs/heads/main' }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.spoticord-accounts.outputs.tags }}
labels: ${{ steps.spoticord-accounts.outputs.labels }}
# Some basic caching of the layers...
cache-from: ${{ steps.repo-uri-string.outputs.lowercase }}:latest-cache
cache-to: ${{ steps.repo-uri-string.outputs.lowercase }}:latest-cache
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://raw.githubusercontent.com/vercel/next.js/canary/examples/with-docker/Dockerfile

# Install dependencies only when needed
FROM node:16-alpine AS deps
FROM --platform=linux/amd64 node:16-alpine 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
Expand All @@ -17,7 +17,7 @@ RUN \


# Rebuild the source code only when needed
FROM node:16-alpine AS builder
FROM --platform=linux/amd64 node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
Expand Down

0 comments on commit 75935cc

Please sign in to comment.