Skip to content

Commit b05e51f

Browse files
authored
Merge branch 'TriliumNext:develop' into sql
2 parents 9efa748 + e2bdfbb commit b05e51f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1022
-194
lines changed

.github/workflows/main-docker.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
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:
13+
14+
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
20+
21+
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
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
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: Extract metadata (tags, labels) for GHCR image
79+
id: ghcr-meta
80+
uses: docker/metadata-action@v4
81+
with:
82+
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
83+
tags: |
84+
type=ref,event=branch
85+
type=ref,event=tag
86+
type=sha
87+
- name: Extract metadata (tags, labels) for DockerHub image
88+
id: dh-meta
89+
uses: docker/metadata-action@v4
90+
with:
91+
images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
92+
tags: |
93+
type=ref,event=branch
94+
type=ref,event=tag
95+
type=sha
96+
- name: Set up node & dependencies
97+
uses: actions/setup-node@v4
98+
with:
99+
node-version: 20
100+
cache: "npm"
101+
- run: npm ci
102+
- name: Run the TypeScript build
103+
run: npx tsc
104+
- name: Create server-package.json
105+
run: cat package.json | grep -v electron > server-package.json
106+
- name: Log in to the GHCR container registry
107+
uses: docker/login-action@v2
108+
with:
109+
registry: ${{ env.GHCR_REGISTRY }}
110+
username: ${{ github.actor }}
111+
password: ${{ secrets.GITHUB_TOKEN }}
112+
- uses: docker/setup-buildx-action@v3
113+
- name: Build and push container image to GHCR
114+
uses: docker/build-push-action@v6
115+
id: ghcr-push
116+
with:
117+
context: .
118+
platforms: ${{ env.PLATFORMS }}
119+
push: true
120+
tags: ${{ steps.ghcr-meta.outputs.tags }}
121+
labels: ${{ steps.ghcr-meta.outputs.labels }}
122+
cache-from: type=gha
123+
cache-to: type=gha,mode=max
124+
- name: Generate and push artifact attestation to GHCR
125+
uses: actions/attest-build-provenance@v1
126+
with:
127+
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
128+
subject-digest: ${{ steps.ghcr-push.outputs.digest }}
129+
push-to-registry: true
130+
- name: Log in to the DockerHub container registry
131+
uses: docker/login-action@v2
132+
with:
133+
registry: ${{ env.DOCKERHUB_REGISTRY }}
134+
username: ${{ secrets.DOCKERHUB_USERNAME }}
135+
password: ${{ secrets.DOCKERHUB_TOKEN }}
136+
- name: Build and push image to DockerHub
137+
uses: docker/build-push-action@v6
138+
id: dh-push
139+
with:
140+
context: .
141+
platforms: ${{ env.PLATFORMS }}
142+
push: true
143+
tags: ${{ steps.dh-meta.outputs.tags }}
144+
labels: ${{ steps.dh-meta.outputs.labels }}
145+
cache-from: type=gha
146+
cache-to: type=gha,mode=max
147+
- name: Generate and push artifact attestation to DockerHub
148+
uses: actions/attest-build-provenance@v1
149+
with:
150+
subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
151+
subject-digest: ${{ steps.dh-push.outputs.digest }}
152+
push-to-registry: true

.github/workflows/main.yml

Lines changed: 4 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ on:
88
paths-ignore:
99
- "docs/**"
1010
- "bin/**"
11+
- ".github/workflows/main-docker.yml"
12+
tags:
13+
- "v*"
1114
workflow_dispatch:
1215

1316
concurrency:
1417
group: ${{ github.workflow }}-${{ github.ref }}
1518
cancel-in-progress: true
1619

17-
env:
18-
GHCR_REGISTRY: ghcr.io
19-
DOCKERHUB_REGISTRY: docker.io
20-
IMAGE_NAME: ${{ github.repository }}
21-
2220
jobs:
2321
build_darwin:
2422
name: Build macOS (x86_64, arm64)
@@ -141,79 +139,4 @@ jobs:
141139
uses: actions/upload-artifact@v4
142140
with:
143141
name: TriliumNext Notes for Windows (Setup)
144-
path: out/make/squirrel.windows/x64/*.exe
145-
build_docker:
146-
name: Build Docker images
147-
runs-on: ubuntu-latest
148-
permissions:
149-
contents: read
150-
packages: write
151-
attestations: write
152-
id-token: write
153-
steps:
154-
- uses: actions/checkout@v4
155-
- name: Extract metadata (tags, labels) for GHCR image
156-
id: ghcr-meta
157-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
158-
with:
159-
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
160-
- name: Extract metadata (tags, labels) for DockerHub image
161-
id: dh-meta
162-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
163-
with:
164-
images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
165-
- name: Set up node & dependencies
166-
uses: actions/setup-node@v4
167-
with:
168-
node-version: 20
169-
cache: "npm"
170-
- run: npm ci
171-
- name: Run the TypeScript build
172-
run: npx tsc
173-
- name: Create server-package.json
174-
run: cat package.json | grep -v electron > server-package.json
175-
- name: Log in to the GHCR container registry
176-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
177-
with:
178-
registry: ${{ env.GHCR_REGISTRY }}
179-
username: ${{ github.actor }}
180-
password: ${{ secrets.GITHUB_TOKEN }}
181-
- uses: docker/setup-buildx-action@v3
182-
- name: Build and push container image to GHCR
183-
uses: docker/build-push-action@v6
184-
id: ghcr-push
185-
with:
186-
context: .
187-
push: true
188-
tags: ${{ steps.ghcr-meta.outputs.tags }}
189-
labels: ${{ steps.ghcr-meta.outputs.labels }}
190-
cache-from: type=gha
191-
cache-to: type=gha,mode=max
192-
- name: Generate and push artifact attestation to GHCR
193-
uses: actions/attest-build-provenance@v1
194-
with:
195-
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
196-
subject-digest: ${{ steps.ghcr-push.outputs.digest }}
197-
push-to-registry: true
198-
- name: Log in to the DockerHub container registry
199-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
200-
with:
201-
registry: ${{ env.DOCKERHUB_REGISTRY }}
202-
username: ${{ secrets.DOCKERHUB_USERNAME }}
203-
password: ${{ secrets.DOCKERHUB_TOKEN }}
204-
- name: Build and push image to DockerHub
205-
uses: docker/build-push-action@v6
206-
id: dh-push
207-
with:
208-
context: .
209-
push: true
210-
tags: ${{ steps.dh-meta.outputs.tags }}
211-
labels: ${{ steps.dh-meta.outputs.labels }}
212-
cache-from: type=gha
213-
cache-to: type=gha,mode=max
214-
- name: Generate and push artifact attestation to DockerHub
215-
uses: actions/attest-build-provenance@v1
216-
with:
217-
subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
218-
subject-digest: ${{ steps.dh-push.outputs.digest }}
219-
push-to-registry: true
142+
path: out/make/squirrel.windows/x64/*.exe

.github/workflows/playwright.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: npx playwright test
22+
- uses: actions/upload-artifact@v4
23+
if: always()
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

.gitignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ build/
55
src/public/app-dist/
66
npm-debug.log
77
yarn-error.log
8+
89
*.db
10+
!integration-tests/db/document.db
11+
integration-tests/db/log
12+
integration-tests/db/sessions
13+
integration-tests/db/backup
14+
integration-tests/db/session_secret.txt
15+
916
config.ini
1017
cert.key
1118
cert.crt
@@ -18,8 +25,11 @@ tmp/
1825

1926
out/
2027

21-
images/app-icons/png/16x16.png
22-
images/app-icons/png/32x32.png
2328
images/app-icons/png/512x512.png
2429
images/app-icons/png/1024x1024.png
25-
images/app-icons/mac/*.png
30+
images/app-icons/mac/*.png
31+
/test-results/
32+
/playwright-report/
33+
/blob-report/
34+
/playwright/.cache/
35+
/playwright/.auth/

Dockerfile

Lines changed: 33 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
@@ -24,27 +26,41 @@ COPY server-package.json package.json
2426
# Copy TypeScript build artifacts into the original directory structure.
2527
RUN ls
2628
RUN cp -R build/src/* src/.
29+
30+
# Copy the healthcheck
31+
RUN cp build/docker_healthcheck.js .
32+
RUN rm docker_healthcheck.ts
33+
2734
RUN rm -r build
2835

2936
# Install app dependencies
30-
RUN set -x \
31-
&& npm install \
32-
&& apk del .build-dependencies \
33-
&& npm run webpack \
34-
&& npm prune --omit=dev \
35-
&& cp src/public/app/share.js src/public/app-dist/. \
36-
&& cp -r src/public/app/doc_notes src/public/app-dist/. \
37-
&& rm -rf src/public/app \
38-
&& 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
3956

4057
# Some setup tools need to be kept
41-
RUN apk add --no-cache su-exec shadow
42-
43-
# Add application user and setup proper volume permissions
44-
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/*
4561

4662
# Start the application
4763
EXPOSE 8080
4864
CMD [ "./start-docker.sh" ]
4965

50-
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)