Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 676bff4

Browse files
committed
fix arm builds
1 parent 36f51ba commit 676bff4

File tree

2 files changed

+160
-142
lines changed

2 files changed

+160
-142
lines changed

.github/workflows/main-docker.yml

Lines changed: 132 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,155 @@
11
on:
2-
push:
3-
branches:
4-
- "develop"
5-
- "feature/update**"
6-
- "feature/server_esm**"
7-
paths-ignore:
8-
- "docs/**"
9-
- "bin/**"
10-
tags:
11-
- "v*"
12-
workflow_dispatch:
2+
push:
3+
branches:
4+
- "develop"
5+
- "feature/update**"
6+
- "feature/server_esm**"
7+
paths-ignore:
8+
- "docs/**"
9+
- "bin/**"
10+
tags:
11+
- "v*"
12+
workflow_dispatch:
1313

1414
env:
15-
GHCR_REGISTRY: ghcr.io
16-
DOCKERHUB_REGISTRY: docker.io
17-
IMAGE_NAME: ${{ github.repository }}
18-
TEST_TAG: triliumnext/notes:test
19-
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
15+
GHCR_REGISTRY: ghcr.io
16+
DOCKERHUB_REGISTRY: docker.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
TEST_TAG: triliumnext/notes:test
19+
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm64/v8
2020

2121
jobs:
22-
test_docker:
23-
name: Check Docker build
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Checkout the repository
27-
uses: actions/checkout@v4
22+
test_docker:
23+
name: Check Docker build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout the repository
27+
uses: actions/checkout@v4
2828

29-
- name: Set up Docker Buildx
30-
uses: docker/setup-buildx-action@v3
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
3131

32-
- name: Set up node & dependencies
33-
uses: actions/setup-node@v4
34-
with:
35-
node-version: 20
36-
cache: "npm"
37-
38-
- run: npm ci
39-
40-
- name: Run the TypeScript build
41-
run: npx tsc
42-
43-
- name: Create server-package.json
44-
run: cat package.json | grep -v electron > server-package.json
45-
46-
- name: Build and export to Docker
47-
uses: docker/build-push-action@v6
48-
with:
49-
context: .
50-
load: true
51-
tags: ${{ env.TEST_TAG }}
52-
cache-from: type=gha
53-
cache-to: type=gha,mode=max
54-
55-
- name: Run the container in the background
56-
run: docker run -d --rm --name trilium_local ${{ env.TEST_TAG }}
57-
58-
- name: Wait for the healthchecks to pass
59-
uses: stringbean/docker-healthcheck-action@v1
60-
with:
61-
container: trilium_local
62-
wait-time: 50
63-
require-status: running
64-
require-healthy: true
65-
66-
build_docker:
67-
name: Build Docker images
68-
runs-on: ubuntu-latest
69-
needs:
70-
- test_docker
71-
permissions:
72-
contents: read
73-
packages: write
74-
attestations: write
75-
id-token: write
76-
steps:
77-
- uses: actions/checkout@v4
78-
- name: Set up QEMU
79-
uses: docker/setup-qemu-action@v3
80-
- name: Extract metadata (tags, labels) for GHCR image
81-
id: ghcr-meta
82-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
83-
with:
84-
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
85-
tags:
86-
- name: Extract metadata (tags, labels) for DockerHub image
87-
id: dh-meta
88-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
89-
with:
90-
images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
9132
- name: Set up node & dependencies
9233
uses: actions/setup-node@v4
9334
with:
9435
node-version: 20
9536
cache: "npm"
37+
9638
- run: npm ci
39+
9740
- name: Run the TypeScript build
9841
run: npx tsc
42+
9943
- name: Create server-package.json
10044
run: cat package.json | grep -v electron > server-package.json
101-
- name: Log in to the GHCR container registry
102-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
103-
with:
104-
registry: ${{ env.GHCR_REGISTRY }}
105-
username: ${{ github.actor }}
106-
password: ${{ secrets.GITHUB_TOKEN }}
107-
- uses: docker/setup-buildx-action@v3
108-
- name: Build and push container image to GHCR
109-
uses: docker/build-push-action@v6
110-
id: ghcr-push
111-
with:
112-
context: .
113-
platforms: ${{ env.PLATFORMS }}
114-
push: true
115-
tags: ${{ steps.ghcr-meta.outputs.tags }}
116-
labels: ${{ steps.ghcr-meta.outputs.labels }}
117-
cache-from: type=gha
118-
cache-to: type=gha,mode=max
119-
- name: Generate and push artifact attestation to GHCR
120-
uses: actions/attest-build-provenance@v1
121-
with:
122-
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
123-
subject-digest: ${{ steps.ghcr-push.outputs.digest }}
124-
push-to-registry: true
125-
- name: Log in to the DockerHub container registry
126-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
127-
with:
128-
registry: ${{ env.DOCKERHUB_REGISTRY }}
129-
username: ${{ secrets.DOCKERHUB_USERNAME }}
130-
password: ${{ secrets.DOCKERHUB_TOKEN }}
131-
- name: Build and push image to DockerHub
45+
46+
- name: Build and export to Docker
13247
uses: docker/build-push-action@v6
133-
id: dh-push
13448
with:
13549
context: .
136-
platforms: ${{ env.PLATFORMS }}
137-
push: true
138-
tags: ${{ steps.dh-meta.outputs.tags }}
139-
labels: ${{ steps.dh-meta.outputs.labels }}
50+
load: true
51+
tags: ${{ env.TEST_TAG }}
14052
cache-from: type=gha
14153
cache-to: type=gha,mode=max
142-
- name: Generate and push artifact attestation to DockerHub
143-
uses: actions/attest-build-provenance@v1
54+
55+
- name: Run the container in the background
56+
run: docker run -d --rm --name trilium_local ${{ env.TEST_TAG }}
57+
58+
- name: Wait for the healthchecks to pass
59+
uses: stringbean/docker-healthcheck-action@v1
14460
with:
145-
subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
146-
subject-digest: ${{ steps.dh-push.outputs.digest }}
147-
push-to-registry: true
148-
61+
container: trilium_local
62+
wait-time: 50
63+
require-status: running
64+
require-healthy: true
65+
66+
build_docker:
67+
name: Build Docker images
68+
runs-on: ubuntu-latest
69+
needs:
70+
- test_docker
71+
permissions:
72+
contents: read
73+
packages: write
74+
attestations: write
75+
id-token: write
76+
strategy:
77+
matrix:
78+
architecture: [linux/amd64, linux/arm64, linux/arm/v7, linux/arm64/v8]
79+
steps:
80+
- uses: actions/checkout@v4
81+
- name: Extract metadata (tags, labels) for GHCR image
82+
id: ghcr-meta
83+
uses: docker/metadata-action@v4
84+
with:
85+
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
86+
tags: |
87+
type=ref,event=branch
88+
type=ref,event=tag
89+
type=sha
90+
- name: Extract metadata (tags, labels) for DockerHub image
91+
id: dh-meta
92+
uses: docker/metadata-action@v4
93+
with:
94+
images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
95+
tags: |
96+
type=ref,event=branch
97+
type=ref,event=tag
98+
type=sha
99+
- name: Set up node & dependencies
100+
uses: actions/setup-node@v4
101+
with:
102+
node-version: 20
103+
cache: "npm"
104+
- run: npm ci
105+
- name: Run the TypeScript build
106+
run: npx tsc
107+
- name: Create server-package.json
108+
run: cat package.json | grep -v electron > server-package.json
109+
- name: Log in to the GHCR container registry
110+
uses: docker/login-action@v2
111+
with:
112+
registry: ${{ env.GHCR_REGISTRY }}
113+
username: ${{ github.actor }}
114+
password: ${{ secrets.GITHUB_TOKEN }}
115+
- uses: docker/setup-buildx-action@v3
116+
- name: Build and push container image to GHCR
117+
uses: docker/build-push-action@v6
118+
id: ghcr-push
119+
with:
120+
context: .
121+
platforms: ${{ matrix.architecture }}
122+
push: true
123+
tags: ${{ steps.ghcr-meta.outputs.tags }}
124+
labels: ${{ steps.ghcr-meta.outputs.labels }}
125+
cache-from: type=gha
126+
cache-to: type=gha,mode=max
127+
- name: Generate and push artifact attestation to GHCR
128+
uses: actions/attest-build-provenance@v1
129+
with:
130+
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
131+
subject-digest: ${{ steps.ghcr-push.outputs.digest }}
132+
push-to-registry: true
133+
- name: Log in to the DockerHub container registry
134+
uses: docker/login-action@v2
135+
with:
136+
registry: ${{ env.DOCKERHUB_REGISTRY }}
137+
username: ${{ secrets.DOCKERHUB_USERNAME }}
138+
password: ${{ secrets.DOCKERHUB_TOKEN }}
139+
- name: Build and push image to DockerHub
140+
uses: docker/build-push-action@v6
141+
id: dh-push
142+
with:
143+
context: .
144+
platforms: ${{ matrix.architecture }}
145+
push: true
146+
tags: ${{ steps.dh-meta.outputs.tags }}
147+
labels: ${{ steps.dh-meta.outputs.labels }}
148+
cache-from: type=gha
149+
cache-to: type=gha,mode=max
150+
- name: Generate and push artifact attestation to DockerHub
151+
uses: actions/attest-build-provenance@v1
152+
with:
153+
subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
154+
subject-digest: ${{ steps.dh-push.outputs.digest }}
155+
push-to-registry: true

Dockerfile

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!!
2-
FROM node:20.15.1-alpine
2+
FROM node:20.15.1-bullseye-slim
33

44
# Configure system dependencies
5-
RUN apk add --no-cache --virtual .build-dependencies \
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
66
autoconf \
77
automake \
88
g++ \
@@ -11,7 +11,9 @@ RUN apk add --no-cache --virtual .build-dependencies \
1111
make \
1212
nasm \
1313
libpng-dev \
14-
python3
14+
python3 \
15+
gosu \
16+
&& rm -rf /var/lib/apt/lists/*
1517

1618
# Create app directory
1719
WORKDIR /usr/src/app
@@ -32,24 +34,33 @@ RUN rm docker_healthcheck.ts
3234
RUN rm -r build
3335

3436
# Install app dependencies
35-
RUN set -x \
36-
&& npm install \
37-
&& apk del .build-dependencies \
38-
&& npm run webpack \
39-
&& npm prune --omit=dev \
40-
&& cp src/public/app/share.js src/public/app-dist/. \
41-
&& cp -r src/public/app/doc_notes src/public/app-dist/. \
42-
&& rm -rf src/public/app \
43-
&& rm src/services/asset_path.ts
37+
RUN set -x
38+
RUN npm install
39+
RUN apt-get purge -y --auto-remove \
40+
autoconf \
41+
automake \
42+
g++ \
43+
gcc \
44+
libtool \
45+
make \
46+
nasm \
47+
libpng-dev \
48+
python3 \
49+
&& rm -rf /var/lib/apt/lists/*
50+
RUN npm run webpack
51+
RUN npm prune --omit=dev
52+
RUN cp src/public/app/share.js src/public/app-dist/.
53+
RUN cp -r src/public/app/doc_notes src/public/app-dist/.
54+
RUN rm -rf src/public/app
55+
RUN rm src/services/asset_path.ts
4456

4557
# Some setup tools need to be kept
46-
RUN apk add --no-cache su-exec shadow
47-
48-
# Add application user and setup proper volume permissions
49-
RUN adduser -s /bin/false node; exit 0
58+
RUN apt-get update && apt-get install -y --no-install-recommends \
59+
gosu \
60+
&& rm -rf /var/lib/apt/lists/*
5061

5162
# Start the application
5263
EXPOSE 8080
5364
CMD [ "./start-docker.sh" ]
5465

55-
HEALTHCHECK --start-period=10s CMD exec su-exec node node docker_healthcheck.js
66+
HEALTHCHECK --start-period=10s CMD exec gosu node node docker_healthcheck.js

0 commit comments

Comments
 (0)