Skip to content

Commit 47123a4

Browse files
committed
Linux ARM64 build
Fix #35
1 parent 01f40ae commit 47123a4

File tree

7 files changed

+128
-48
lines changed

7 files changed

+128
-48
lines changed

.github/workflows/build.yaml

+100-40
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os:
16-
- ubuntu-22.04
17-
- macos-12 # Intel
18-
- macos-13-xlarge # Apple silicon
16+
- ubuntu-24.04
17+
- macos-13 # Intel
18+
- macos-14 # Apple silicon
1919
- windows-2022
2020
ghc-version:
2121
- "8.8"
@@ -24,20 +24,22 @@ jobs:
2424
- "9.2"
2525
- "9.4"
2626
exclude:
27-
- os: macos-12
27+
- os: macos-13
2828
ghc-version: "8.10"
29-
- os: macos-12
29+
- os: macos-13
3030
ghc-version: "9.0"
31-
- os: macos-12
31+
- os: macos-13
3232
ghc-version: "9.2"
33-
- os: macos-13-xlarge
33+
- os: macos-14
3434
ghc-version: "8.8"
35-
- os: macos-13-xlarge
35+
- os: macos-14
3636
ghc-version: "8.10"
37-
- os: macos-13-xlarge
37+
- os: macos-14
3838
ghc-version: "9.0"
39-
- os: macos-13-xlarge
39+
- os: macos-14
4040
ghc-version: "9.2"
41+
- os: windows-2022
42+
ghc-version: "8.8"
4143
- os: windows-2022
4244
ghc-version: "8.10"
4345
- os: windows-2022
@@ -70,6 +72,10 @@ jobs:
7072
%APPDATA%\cabal\store
7173
%APPDATA%\stack
7274
key: stack-${{ matrix.os }}-ghc-${{ matrix.version }}
75+
- name: Install dependencies (Linux)
76+
if: "startsWith(matrix.os, 'ubuntu-')"
77+
run: |
78+
sudo apt install libbz2-dev
7379
- name: Install Haskell Stack (if not installed)
7480
shell: bash
7581
run: |
@@ -121,14 +127,8 @@ jobs:
121127
matrix.ghc-version == '9.2'
122128
shell: bash
123129
run: |
124-
curl -L -o /tmp/pandoc.deb \
125-
https://github.com/jgm/pandoc/releases/download/2.14.2/pandoc-2.14.2-1-amd64.deb
126-
sudo dpkg -i /tmp/pandoc.deb
127-
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
128-
sudo add-apt-repository ppa:rmescandon/yq
129-
sudo apt update
130-
sudo apt-get install -y yq
131-
bash scripts/haddock-prologue/build.sh
130+
sudo apt-get install -y pandoc yq
131+
PATH="/usr/bin:$PATH" bash scripts/haddock-prologue/build.sh
132132
- name: Copy docs
133133
if: >-
134134
startsWith(matrix.os, 'ubuntu-') &&
@@ -178,9 +178,8 @@ jobs:
178178
fail-fast: false
179179
matrix:
180180
os:
181-
- ubuntu-22.04
182-
- macos-12 # Intel
183-
- macos-13-xlarge # Apple silicon
181+
- ubuntu-24.04
182+
- macos-14 # Apple silicon
184183
- windows-2022
185184
steps:
186185
- uses: actions/checkout@v4
@@ -266,12 +265,21 @@ jobs:
266265
267266
image:
268267
name: Docker image
269-
runs-on: ubuntu-22.04
268+
strategy:
269+
fail-fast: false
270+
matrix:
271+
os:
272+
- ubuntu-24.04
273+
- ubuntu-24.04-arm
274+
runs-on: ${{ matrix.os }}
270275
env:
271276
DOCKERHUB_IMAGE_NAME: seonbi
272277
outputs:
273278
image-ghcr: ghcr.io/${{ github.repository }}/bin@${{ steps.push-image.outputs.digest }}
274279
image-dockerhub: docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}@${{ steps.push-image.outputs.digest }}
280+
tag: ${{ steps.values.outputs.tag }}
281+
labels: ${{ steps.values.outputs.labels }}
282+
arch: ${{ steps.values.outputs.arch }}
275283
steps:
276284
- uses: actions/checkout@v4
277285
with:
@@ -303,6 +311,11 @@ jobs:
303311
else
304312
echo labels= >> "$GITHUB_OUTPUT"
305313
fi
314+
if [[ "$RUNNER_ARCH" = "ARM64" ]]; then
315+
echo arch=arm64 >> "$GITHUB_OUTPUT"
316+
else
317+
echo arch=amd64 >> "$GITHUB_OUTPUT"
318+
fi
306319
- id: push-image
307320
uses: docker/build-push-action@v6
308321
with:
@@ -313,19 +326,48 @@ jobs:
313326
org.opencontainers.image.url=${{ github.event.repository.html_url }}
314327
${{ steps.values.outputs.labels }}
315328
tags: |
316-
ghcr.io/${{ github.repository }}/bin:${{ steps.values.outputs.tag }}
317-
${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ steps.values.outputs.tag }}
329+
ghcr.io/${{ github.repository }}/bin:${{ steps.values.outputs.tag }}-${{ steps.values.outputs.arch }}
330+
${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ steps.values.outputs.tag }}-${{ steps.values.outputs.arch }}
318331
provenance: false # https://community.fly.io/t/deploying-to-fly-via-github-action-failing/10171/33
319332

333+
image-manifest:
334+
name: Create and push manifest images
335+
if: github.event_name != 'pull_request'
336+
needs:
337+
- image
338+
runs-on: ubuntu-24.04
339+
env:
340+
DOCKERHUB_IMAGE_NAME: seonbi
341+
steps:
342+
- uses: docker/login-action@v3
343+
with:
344+
registry: ghcr.io
345+
username: ${{ github.repository_owner }}
346+
password: ${{ github.token }}
347+
- uses: docker/login-action@v3
348+
with:
349+
username: ${{ vars.DOCKERHUB_USERNAME }}
350+
password: ${{ secrets.DOCKERHUB_TOKEN }}
351+
- uses: Noelware/[email protected]
352+
with:
353+
inputs: ghcr.io/${{ github.repository }}/bin:${{ needs.image.outputs.tag }}
354+
images: ghcr.io/${{ github.repository }}/bin:${{ needs.image.outputs.tag }}-amd64,ghcr.io/${{ github.repository }}/bin:${{ needs.image.outputs.tag }}-arm64
355+
push: true
356+
- uses: Noelware/[email protected]
357+
with:
358+
inputs: docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ needs.image.outputs.tag }}
359+
images: docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ needs.image.outputs.tag }}-amd64,docker.io/${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ needs.image.outputs.tag }}-arm64
360+
push: true
361+
320362
fly:
321363
name: Deploy seonbi-api to Fly.io
322364
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
323365
needs:
324366
- image
325367
env:
326368
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
327-
IMAGE: ${{ needs.image.outputs.image-ghcr }}
328-
runs-on: ubuntu-22.04
369+
IMAGE: ghcr.io/${{ github.repository }}/bin:${{ needs.image.outputs.tag }}-amd64
370+
runs-on: ubuntu-24.04
329371
steps:
330372
- uses: actions/checkout@v4
331373
- uses: superfly/flyctl-actions/setup-flyctl@master
@@ -345,36 +387,54 @@ jobs:
345387
needs:
346388
- build
347389
- image
348-
runs-on: ubuntu-22.04
390+
runs-on: ubuntu-24.04
349391
steps:
350392
- uses: actions/checkout@v4
351393
- uses: actions/download-artifact@v4
352394
with:
353-
name: binaries-macos-13-xlarge-ghc-9.4
395+
name: binaries-macos-14-ghc-9.4
354396
path: /tmp/binaries-macos-arm64
355397
- uses: actions/download-artifact@v4
356398
with:
357-
name: binaries-macos-12-ghc-9.4
399+
name: binaries-macos-13-ghc-9.4
358400
path: /tmp/binaries-macos-x86_64
359401
- uses: actions/download-artifact@v4
360402
with:
361403
name: binaries-windows-2022-ghc-9.2
362404
path: /tmp/binaries-windows
405+
- uses: docker/setup-qemu-action@v3
406+
with:
407+
platforms: arm64
408+
- uses: docker/setup-buildx-action@v3
363409
- run: |
364410
set -e
365411
mkdir -p /tmp/dists
366-
# Linux
367-
docker pull "$IMAGE"
368-
mkdir -p /tmp/binaries-linux
369-
docker run -i "$IMAGE" cat /usr/local/bin/seonbi \
370-
> /tmp/binaries-linux/seonbi
371-
docker run -i "$IMAGE" cat /usr/local/bin/seonbi-api \
372-
> /tmp/binaries-linux/seonbi-api
373-
pushd /tmp/binaries-linux
412+
# Linux (amd64)
413+
docker pull "$IMAGE-amd64"
414+
mkdir -p /tmp/binaries-linux-amd64
415+
docker run -i "$IMAGE-amd64" cat /usr/local/bin/seonbi \
416+
> /tmp/binaries-linux-amd64/seonbi
417+
docker run -i "$IMAGE-amd64" cat /usr/local/bin/seonbi-api \
418+
> /tmp/binaries-linux-amd64/seonbi-api
419+
pushd /tmp/binaries-linux-amd64
374420
chmod +x *
375421
cp "$GITHUB_WORKSPACE/"{LICENSE,README.md,CHANGES.md} ./
376422
tar cvfj /tmp/dists/seonbi.linux-x86_64.tar.bz2 *
377423
popd
424+
# Linux (arm64)
425+
docker pull "$IMAGE-arm64"
426+
mkdir -p /tmp/binaries-linux-arm64
427+
docker run -i --platform linux/arm64 "$IMAGE-arm64" \
428+
cat /usr/local/bin/seonbi \
429+
> /tmp/binaries-linux-arm64/seonbi
430+
docker run -i --platform linux/arm64 "$IMAGE-arm64" \
431+
cat /usr/local/bin/seonbi-api \
432+
> /tmp/binaries-linux-arm64/seonbi-api
433+
pushd /tmp/binaries-linux-arm64
434+
chmod +x *
435+
cp "$GITHUB_WORKSPACE/"{LICENSE,README.md,CHANGES.md} ./
436+
tar cvfj /tmp/dists/seonbi.linux-arm64.tar.bz2 *
437+
popd
378438
# macOS (Apple silicon)
379439
pushd /tmp/binaries-macos-arm64
380440
chmod +x *
@@ -393,7 +453,7 @@ jobs:
393453
zip /tmp/dists/seonbi.win64.zip *
394454
popd
395455
env:
396-
IMAGE: ${{ needs.image.outputs.image-ghcr }}
456+
IMAGE: ghcr.io/${{ github.repository }}/bin:${{ needs.image.outputs.tag }}
397457
- uses: actions/upload-artifact@v4
398458
with:
399459
name: dists-untagged
@@ -404,12 +464,12 @@ jobs:
404464
needs:
405465
- build
406466
- binaries
407-
runs-on: ubuntu-22.04
467+
runs-on: ubuntu-24.04
408468
steps:
409469
- uses: actions/checkout@v4
410470
- uses: actions/download-artifact@v4
411471
with:
412-
name: sdist-ubuntu-22.04-ghc-9.4
472+
name: sdist-ubuntu-24.04-ghc-9.4
413473
path: /tmp/sdist
414474
- uses: actions/download-artifact@v4
415475
with:

CHANGES.md

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ Version 0.5.0
66

77
To be released.
88

9+
- Added prebuilt executable binaries for Linux ARM64 (linux-arm64).
10+
11+
- The official Docker images are now multi-platform (linux/amd64 and
12+
linux/arm64). [[#35]]
13+
14+
[#35]: https://github.com/dahlia/seonbi/issues/35
15+
916

1017
Version 0.4.0
1118
-------------

Dockerfile

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# To correctly make a statically-linked binary, we use Alpine Linux.
22
# The distro entirely uses musl instead of glibc which is unfriendly to be
33
# statically linked.
4-
FROM docker.io/amd64/alpine:3.19 AS build
4+
FROM docker.io/alpine:3.19 AS build
55

66
LABEL "org.opencontainers.image.title"="Seonbi"
77
LABEL "org.opencontainers.image.licenses"="LGPL-2.1"
@@ -11,9 +11,13 @@ RUN apk add --no-cache \
1111
bzip2-dev=1.0.8-r6 \
1212
ghc=9.4.7-r1 \
1313
libbz2=1.0.8-r6 \
14+
xz=5.4.5-r0 \
1415
zlib-dev=1.3.1-r0 \
1516
zlib-static=1.3.1-r0
16-
RUN wget -qO- https://get.haskellstack.org/ | sh
17+
18+
RUN wget -q "https://github.com/commercialhaskell/stack/releases/download/v3.3.1/stack-3.3.1-linux-$(uname -m)-bin" \
19+
&& mv "stack-3.3.1-linux-$(uname -m)-bin" /usr/bin/stack \
20+
&& chmod +x /usr/bin/stack
1721

1822
RUN stack config set system-ghc --global true
1923

@@ -26,8 +30,9 @@ WORKDIR /src/seonbi
2630
# Docker will cache this command as a layer, freeing us up to
2731
# modify source code without re-installing dependencies
2832
# (unless the .cabal file changes!)
29-
RUN stack setup
33+
RUN stack setup --system-ghc
3034
RUN stack build \
35+
--system-ghc \
3136
--only-snapshot \
3237
--flag seonbi:iconv \
3338
--flag seonbi:static
@@ -36,11 +41,12 @@ COPY . /src/seonbi
3641
RUN cp /src/seonbi/stack-ghc-9.4.yaml /src/seonbi/stack.yaml
3742

3843
RUN stack build \
44+
--system-ghc \
3945
--flag seonbi:iconv \
4046
--flag seonbi:static \
4147
--copy-bins
4248

43-
FROM docker.io/amd64/alpine:3.14
49+
FROM docker.io/alpine:3.19
4450

4551
COPY --from=build /root/.local/bin/seonbi* /usr/local/bin/
4652
ENV LANG=en_US.UTF-8

scripts/deno/mod.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ const STABLE_DOWNLOAD_URLS: DownloadUrls = {
143143
linux: {
144144
x86_64:
145145
"https://github.com/dahlia/seonbi/releases/download/0.5.0/seonbi-0.5.0.linux-x86_64.tar.bz2",
146-
aarch64: undefined,
146+
aarch64:
147+
"https://github.com/dahlia/seonbi/releases/download/0.5.0/seonbi-0.5.0.linux-arm64.tar.bz2",
147148
},
148149
darwin: {
149150
x86_64:
@@ -162,7 +163,8 @@ const NIGHTLY_DOWNLOAD_URLS: DownloadUrls = {
162163
linux: {
163164
x86_64:
164165
"https://dahlia.github.io/seonbi/dists/latest/seonbi.linux-x86_64.tar.bz2",
165-
aarch64: undefined,
166+
aarch64:
167+
"https://dahlia.github.io/seonbi/dists/latest/seonbi.linux-arm64.tar.bz2",
166168
},
167169
darwin: {
168170
x86_64:

scripts/haddock-prologue/build.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ cp "$package" "$backup"
1515
cwd="$(pwd)"
1616
exit_code=1
1717
{
18-
yq write --inplace "$package" description "$description"
18+
yq \
19+
-y \
20+
--arg description "$description" \
21+
'.description = $description' \
22+
"$backup" > "$package"
1923
cd "$root"
2024
stack haddock --no-haddock-deps
2125
cd "$(stack path --dist-dir)/doc/html/"

setup/action.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ runs:
4242
4343
suffixes = {
4444
('Linux', 'X64'): 'linux-x86_64.tar.bz2',
45+
('Linux', 'ARM64'): 'linux-arm64.tar.bz2',
4546
('macOS', 'X64'): 'macos-x86_64.tar.bz2',
4647
('macOS', 'ARM64'): 'macos-arm64.tar.bz2',
4748
('Windows', 'X64'): 'win64.zip',

stack-ghc-9.4.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-21.25
1+
resolver: lts-21.21
22
packages:
33
- .
44
extra-deps:

0 commit comments

Comments
 (0)