Skip to content

Commit

Permalink
Fix code diff highlighting (#1482)
Browse files Browse the repository at this point in the history
Our Jekyll site has a dodgy highlighter :(

I pushed this via `beta` branch to the site to test that it works:
https://seek-oss.github.io/skuba/docs/deep-dives/arm64.html

Co-authored-by: Sam Chung <samc@seek.com.au>
  • Loading branch information
72636c and samchungy committed Mar 19, 2024
1 parent ef04794 commit 15842f1
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 92 deletions.
186 changes: 97 additions & 89 deletions docs/deep-dives/arm64.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,24 @@ If you'd like to build and run your projects on ARM64 hardware,
create a Buildkite cluster with a Graviton-based instance type.
In a `vCurrent` strategy:

<!-- prettier-ignore -->
```diff
schemaVersion: vCurrent
clusters:
- name: cicd # Existing cluster

instanceType: t3.large
rootVolumeSize: 8

# ...
+
+ - name: graviton # New cluster; choose a name you like
+
+ cpuArchitecture: arm64
+ instanceType: t4g.large # Required; g is for Graviton
+ rootVolumeSize: 8 # Optional
+
+ # ...
schemaVersion: vCurrent
clusters:
- name: cicd # Existing cluster
instanceType: t3.large
rootVolumeSize: 8
# ...
+
+ - name: graviton # New cluster; choose a name you like
+
+ cpuArchitecture: arm64
+ instanceType: t4g.large # Required; g is for Graviton
+ rootVolumeSize: 8 # Optional
+
+ # ...
```

Repeat this process for all accounts and strategies under your remit,
Expand All @@ -58,22 +59,22 @@ This approach allows you to gradually migrate existing projects over to the new
then delete the original clusters once complete:

```diff
schemaVersion: vCurrent
clusters:
- - name: cicd
schemaVersion: vCurrent
clusters:
- - name: cicd
-
- instanceType: t3.large
- rootVolumeSize: 8
- instanceType: t3.large
- rootVolumeSize: 8
-
- # ...
- # ...
-
- name: graviton
- name: graviton

cpuArchitecture: arm64
instanceType: t4g.large
rootVolumeSize: 8
cpuArchitecture: arm64
instanceType: t4g.large
rootVolumeSize: 8

# ...
# ...
```

See [Builds at SEEK] and the [Gantry ARM reference] for more information.
Expand Down Expand Up @@ -132,71 +133,75 @@ you can revert your project to be compatible with AMD64 hardware.
Point your `agents.queue`s back to the original cluster(s) in `pipeline.yml`:

```diff
agents:
- queue: my-prod-account:graviton
+ queue: my-prod-account:cicd
agents:
- queue: my-prod-account:graviton
+ queue: my-prod-account:cicd
steps:
- label: Prod
steps:
- label: Prod
- label: Dev
agents:
- queue: my-dev-account:graviton
+ queue: my-dev-account:cicd
- label: Dev
agents:
- queue: my-dev-account:graviton
+ queue: my-dev-account:cicd
```

Replace the relevant `--platform` flags in your Dockerfile(s):

```diff
- FROM --platform=arm64 node:20-alpine AS dev-deps
+ FROM --platform=amd64 node:20-alpine AS dev-deps
```

```diff
- FROM --platform=arm64 gcr.io/distroless/nodejs20-debian12 AS runtime
+ FROM --platform=amd64 gcr.io/distroless/nodejs20-debian12 AS runtime
```

For a [Gantry] service,
modify `cpuArchitecture` property on the `ContainerImage` and `Service` resources in `gantry.build.yml` and `gantry.apply.yml`:

<!-- prettier-ignore -->
```diff
kind: ContainerImage
schemaVersion: v0.0
kind: ContainerImage
schemaVersion: v0.0
- cpuArchitecture: arm64
+ cpuArchitecture: amd64
...
...
```

<!-- prettier-ignore -->
```diff
kind: Service
schemaVersion: v0.0
kind: Service
schemaVersion: v0.0
- cpuArchitecture: arm64
+ cpuArchitecture: amd64
...
...
```

For an [AWS CDK] worker,
modify the `architecture` property on the Lambda function resource in `infra/appStack.ts`:

```diff
const worker = new aws_lambda.Function(this, 'worker', {
- architecture: aws_lambda.Architecture.ARM_64,
+ architecture: aws_lambda.Architecture.X86_64,
});
const worker = new aws_lambda.Function(this, 'worker', {
- architecture: aws_lambda.Architecture.ARM_64,
+ architecture: aws_lambda.Architecture.X86_64,
});
```

For a [Serverless] worker,
modify the `provider.architecture` property in `serverless.yml`:

```diff
provider:
- architecture: arm64
+ architecture: x86_64
provider:
- architecture: arm64
+ architecture: x86_64
```

---
Expand All @@ -211,9 +216,9 @@ Your default pipeline should be defined in [`.buildkite/pipeline.yml`],
though you may have auxiliary pipelines under a similar or nested directory.

```diff
agents:
- queue: my-prod-account:cicd
+ queue: my-prod-account:graviton # Should be the new name you chose above
agents:
- queue: my-prod-account:cicd
+ queue: my-prod-account:graviton # Should be the new name you chose above
steps:
- label: Prod
Expand All @@ -229,9 +234,9 @@ Set the `--platform=arm64` flag on each external [`FROM`] command in your Docker
```diff
- FROM node:20-alpine AS dev-deps
+ FROM --platform=arm64 node:20-alpine AS dev-deps
```

# ...
```diff
- FROM gcr.io/distroless/nodejs20-debian12 AS runtime
+ FROM --platform=arm64 gcr.io/distroless/nodejs20-debian12 AS runtime
```
Expand Down Expand Up @@ -275,24 +280,26 @@ As these have no set naming convention, you can look for:
Once you have located these files,
set the `cpuArchitecture` property on the `ContainerImage` and `Service` resources:

<!-- prettier-ignore -->
```diff
kind: ContainerImage
schemaVersion: v0.0
kind: ContainerImage
schemaVersion: v0.0
+ cpuArchitecture: arm64
...
...
```

<!-- prettier-ignore -->
```diff
kind: Service
schemaVersion: v0.0
kind: Service
schemaVersion: v0.0
+ cpuArchitecture: arm64
...
...
```

### AWS CDK
Expand All @@ -312,33 +319,34 @@ Once you have located this file,
set the `architecture` property on the Lambda function resource:

```diff
const worker = new aws_lambda.Function(this, 'worker', {
+ architecture: aws_lambda.Architecture.ARM_64,
runtime: aws_lambda.Runtime.NODEJS_20_X,
// ...
});
const worker = new aws_lambda.Function(this, 'worker', {
+ architecture: aws_lambda.Architecture.ARM_64,
runtime: aws_lambda.Runtime.NODEJS_20_X,
// ...
});
```

```diff
const worker = new aws_lambda_nodejs.NodejsFunction(this, 'worker', {
+ architecture: aws_lambda.Architecture.ARM_64,
runtime: aws_lambda.Runtime.NODEJS_20_X,
// ...
});
const worker = new aws_lambda_nodejs.NodejsFunction(this, 'worker', {
+ architecture: aws_lambda.Architecture.ARM_64,
runtime: aws_lambda.Runtime.NODEJS_20_X,
// ...
});
```

### Serverless

For a [Serverless] worker, set the `provider.architecture` property in [`serverless.yml`]:

<!-- prettier-ignore -->
```diff
provider:
name: aws
+ architecture: arm64
runtime: nodejs20.x
...
provider:
name: aws
+ architecture: arm64
runtime: nodejs20.x
...
```

[`.buildkite/pipeline.yml`]: https://buildkite.com/docs/pipelines/defining-steps#customizing-the-pipeline-upload-path
Expand Down
3 changes: 0 additions & 3 deletions docs/deep-dives/pnpm.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
+ pnpm fetch
```

<!-- prettier-ignore -->
Move the `dst` of the ephemeral `.npmrc` from `/workdir/.npmrc` to `/root/.npmrc`,
and use a [bind mount] in place of `COPY` to mount `pnpm-lock.yaml`.

Expand Down Expand Up @@ -275,8 +274,6 @@ This migration guide assumes that your project was scaffolded with a **skuba** t
ENV NODE_ENV=production
```

<!-- prettier-ignore -->

15. Modify plugins in `.buildkite/pipeline.yml`

Your build pipeline may have previously output an ephemeral `.npmrc` with an auth token on the build agent.
Expand Down

0 comments on commit 15842f1

Please sign in to comment.