Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/composite/build-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
ENVIRONMENT:
description: "'staging' or 'production'"
required: true
ARCH:
description: "Target architecture to build natively (amd64 or arm64)."
required: false
default: amd64

outputs:
tag:
Expand Down Expand Up @@ -46,4 +50,4 @@ runs:
- name: Run script
id: build-image
shell: bash
run: bun run .github/scripts/src/build-image --environment "${{ inputs.ENVIRONMENT }}"
run: bun run .github/scripts/src/build-image --environment "${{ inputs.ENVIRONMENT }}" --arch="${{ inputs.ARCH }}"
2 changes: 1 addition & 1 deletion .github/composite/setup-ci/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ runs:
using: "composite"
steps:
- name: Setup
uses: tahminator/pipeline/actions/setup@1.0.73
uses: tahminator/pipeline/actions/setup@07fc9d27be126e0e9905af56e5d1b74440592626 #1.0.89
with:
INSTALL_SOPS: true
SECRETS: ${{ inputs.SECRETS }}
Expand Down
14 changes: 11 additions & 3 deletions .github/scripts/src/build-image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { hideBin } from "yargs/helpers";

process.env.TZ = "America/New_York";

const { environment, getGhaOutput, githubOutputFile, dockerFileName } =
const { environment, getGhaOutput, githubOutputFile, dockerFileName, arch } =
await yargs(hideBin(process.argv))
.option("environment", {
choices: ["staging", "production"] satisfies Environment[],
Expand All @@ -32,9 +32,17 @@ const { environment, getGhaOutput, githubOutputFile, dockerFileName } =
type: "string",
default: "Dockerfile",
})
.option("arch", {
choices: ["amd64", "arm64"] as const,
describe: "Docker build architecture",
default: "amd64" as const,
})
.strict()
.parse();

const dockerRepository = arch === "arm64" ? "patchats-arm" : "patchats";
const platforms = [`linux/${arch}`];

async function main() {
const DOCKER_HUB_PAT = process.env.DOCKER_HUB_PAT;

Expand Down Expand Up @@ -66,10 +74,10 @@ async function main() {
const gitSha = (await $`git rev-parse --short HEAD`.text()).trim();

await dockerClient.buildImage({
dockerRepository: `patchats`,
dockerRepository,
dockerFileLocation: `infra/${dockerFileName}`,
tags: [`${tagPrefix}${timestamp}`, `${tagPrefix}${gitSha}`],
platforms: ["linux/amd64", "linux/arm64"],
platforms,
});

if (getGhaOutput) {
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/src/update-tag/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function main() {
manifestRepo: ["Patina-Network", "k8s-manifests"],
originRepo: ["Patina-Network", "patchats"],
kustomizationFilePath: "base/production/patchats/kustomization.yaml",
imageName: "patinanetwork/patchats",
imageName: "patinanetwork/patchats-arm",
newTag: gitSha,
environment: "production",
});
Expand All @@ -51,7 +51,7 @@ async function main() {
manifestRepo: ["Patina-Network", "k8s-manifests"],
originRepo: ["Patina-Network", "patchats"],
kustomizationFilePath: "base/staging/patchats/kustomization.yaml",
imageName: "patinanetwork/patchats",
imageName: "patinanetwork/patchats-arm",
newTag: `staging-${gitSha}`,
environment: "staging",
});
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ jobs:
shell: bash
run: echo "skipping db test"


run-backend-instance:
name: Test Run Backend Instance
runs-on: ubuntu-latest
Expand All @@ -123,10 +122,18 @@ jobs:
uses: ./.github/composite/run-backend-instance

build-image:
name: Build Docker Image & Upload to Registry
runs-on: ubuntu-latest
name: Build Docker Image & Upload to Registry (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
needs: [frontend-test, run-local-db, run-backend-instance]

strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm

steps:
- name: Checkout repository
uses: actions/checkout@v6
Expand All @@ -143,6 +150,7 @@ jobs:
uses: ./.github/composite/build-image
with:
ENVIRONMENT: production
ARCH: ${{ matrix.arch }}

migrate-database:
name: Migrate production database
Expand Down Expand Up @@ -189,4 +197,4 @@ jobs:
- name: Run Workflow
uses: ./.github/composite/update-tag
with:
ENVIRONMENT: production
ENVIRONMENT: production
13 changes: 11 additions & 2 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,18 @@ jobs:
uses: ./.github/composite/run-backend-instance

buildImage:
name: Build Docker Image & Upload to Registry
runs-on: ubuntu-latest
name: Build Docker Image & Upload to Registry (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
needs: [frontendTest, runLocalDb, runBackendInstance]

strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm

steps:
- name: Checkout repository
uses: actions/checkout@v6
Expand All @@ -133,6 +141,7 @@ jobs:
uses: ./.github/composite/build-image
with:
ENVIRONMENT: staging
ARCH: ${{ matrix.arch }}

migrateDatabase:
name: Migrate Staging Database
Expand Down
Loading