From 883e71612cb0bfab079fafabe9c6caee74e445ca Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Wed, 7 Aug 2024 13:39:56 -0400 Subject: [PATCH 01/13] Use `triliumnext/notes` as image in `docker-compose.yml` Also added comments to `docker-compose.yml` and removed unused volumes --- docker-compose.yml | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6798574ac..329db7d25 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,23 @@ +# TL;DR: # Running `docker-compose up` will create/use the "trilium-data" directory in the user home # Run `TRILIUM_DATA_DIR=/path/of/your/choice docker-compose up` to set a different directory -version: '2.1' -services: - trilium: - image: zadam/trilium - restart: always - environment: - - TRILIUM_DATA_DIR=/home/node/trilium-data - ports: - - "8080:8080" - volumes: - - ${TRILIUM_DATA_DIR:-~/trilium-data}:/home/node/trilium-data +# To run in the background, use `docker-compose up -d` -volumes: - trilium: +services: + trilium: + # Optionally, replace `latest` with a version tag like `v0.90.3` + # Using `latest` may cause unintended updates to the container + image: triliumnext/notes:latest + # Restart the container unless it was stopped by the user + restart: unless-stopped + environment: + - TRILIUM_DATA_DIR=/home/node/trilium-data + ports: + # By default, Trilium will be available at http://localhost:8080 + # It will also be accessible at http://:8080 + # You might want to limit this with something like Docker Networks, reverse proxies, or firewall rules, such as UFW + - '8080:8080' + volumes: + # Unless TRILIUM_DATA_DIR is set, the data will be stored in the "trilium-data" directory in the home directory. + # This can also be changed with by replacing the line below with `- /path/of/your/choice:/home/node/trilium-data + - ${TRILIUM_DATA_DIR:-~/trilium-data}:/home/node/trilium-data From 4bc24246ab5289e2f8f6d3f15a6d2475c6265e07 Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:51:29 -0400 Subject: [PATCH 02/13] Update Docker image tag in build script --- bin/build-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build-docker.sh b/bin/build-docker.sh index 9d614eb2b..c2e921169 100755 --- a/bin/build-docker.sh +++ b/bin/build-docker.sh @@ -10,7 +10,7 @@ cat package.json | grep -v electron > server-package.json echo "Compiling typescript..." npx tsc -sudo docker build -t zadam/trilium:$VERSION --network host -t zadam/trilium:$SERIES . +sudo docker build -t triliumnext/notes:$VERSION --network host -t zadam/trilium:$SERIES . if [[ $VERSION != *"beta"* ]]; then sudo docker tag zadam/trilium:$VERSION zadam/trilium:latest From b7ce4d04baf5523fa30860e897054654a050623d Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:06:40 -0400 Subject: [PATCH 03/13] revert spacing to what it was before --- docker-compose.yml | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 329db7d25..83f0fcc31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,21 @@ -# TL;DR: # Running `docker-compose up` will create/use the "trilium-data" directory in the user home # Run `TRILIUM_DATA_DIR=/path/of/your/choice docker-compose up` to set a different directory # To run in the background, use `docker-compose up -d` - services: - trilium: - # Optionally, replace `latest` with a version tag like `v0.90.3` - # Using `latest` may cause unintended updates to the container - image: triliumnext/notes:latest - # Restart the container unless it was stopped by the user - restart: unless-stopped - environment: - - TRILIUM_DATA_DIR=/home/node/trilium-data - ports: - # By default, Trilium will be available at http://localhost:8080 - # It will also be accessible at http://:8080 - # You might want to limit this with something like Docker Networks, reverse proxies, or firewall rules, such as UFW - - '8080:8080' - volumes: - # Unless TRILIUM_DATA_DIR is set, the data will be stored in the "trilium-data" directory in the home directory. - # This can also be changed with by replacing the line below with `- /path/of/your/choice:/home/node/trilium-data - - ${TRILIUM_DATA_DIR:-~/trilium-data}:/home/node/trilium-data + trilium: + # Optionally, replace `latest` with a version tag like `v0.90.3` + # Using `latest` may cause unintended updates to the container + image: triliumnext/notes:latest + # Restart the container unless it was stopped by the user + restart: unless-stopped` + environment: + - TRILIUM_DATA_DIR=/home/node/trilium-data + ports: + # By default, Trilium will be available at http://localhost:8080 + # It will also be accessible at http://:8080 + # You might want to limit this with something like Docker Networks, reverse proxies, or firewall rules, such as UFW + - '8080:8080' + volumes: + # Unless TRILIUM_DATA_DIR is set, the data will be stored in the "trilium-data" directory in the home directory. + # This can also be changed with by replacing the line below with `- /path/of/your/choice:/home/node/trilium-data + - ${TRILIUM_DATA_DIR:-~/trilium-data}:/home/node/trilium-data From 5fbda79dbe8a5f3337e23692d2612c10031add94 Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:21:13 -0400 Subject: [PATCH 04/13] Remove erroneous backtick --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 83f0fcc31..d6f5a3c65 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: # Using `latest` may cause unintended updates to the container image: triliumnext/notes:latest # Restart the container unless it was stopped by the user - restart: unless-stopped` + restart: unless-stopped environment: - TRILIUM_DATA_DIR=/home/node/trilium-data ports: From 3cc3c751b42a73b2cd8e686df57ec30ba8b68627 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 8 Aug 2024 19:23:37 +0300 Subject: [PATCH 05/13] electron: Fix missing icons (closes #311) --- .gitignore | 2 -- images/app-icons/png/16x16.png | Bin 0 -> 626 bytes images/app-icons/png/32x32.png | Bin 0 -> 1313 bytes 3 files changed, 2 deletions(-) create mode 100644 images/app-icons/png/16x16.png create mode 100644 images/app-icons/png/32x32.png diff --git a/.gitignore b/.gitignore index 91e8f08c3..a56c97182 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,6 @@ tmp/ out/ -images/app-icons/png/16x16.png -images/app-icons/png/32x32.png images/app-icons/png/512x512.png images/app-icons/png/1024x1024.png images/app-icons/mac/*.png diff --git a/images/app-icons/png/16x16.png b/images/app-icons/png/16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..4645fe0568ccb6acd5db0f654209fdd7ba3b2599 GIT binary patch literal 626 zcmV-&0*(ENP)E zIQd}zkYeP3ka7#7Y@T$YVCuzW@5l11*v07@B+F=d?fEoa05X(8DxtFa!Je^R=KdO|H z0p?0yassVE2}Qyk9G}@aQ>B==%Ml&eMVOr?DG=tfRXGO z#K!PuJrvt9mDzXiDgdkwv2^`l8jg8~n0A_2j-r9kGqdiVdm5vMb73_?2&kfXtB7&q z#K`%@6)S6RA)94ouQ(6RE$Xbh896mJ-3~_EB>|vZ^LEQZaXVjF*u>wz%T%vi+}jSf z<{@ccY?a@>LU|Qal8^%aah{vPxv+Xb)J=5RfCy%Mrj8dQ0rT_o{ M07*qoM6N<$f;RUVwEzGB literal 0 HcmV?d00001 diff --git a/images/app-icons/png/32x32.png b/images/app-icons/png/32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..dbe57df0ec448cdbca93f7a9d2381954c0c582ff GIT binary patch literal 1313 zcmV++1>X9JP)7!iwM9 znVIwd|K`igH#5Y{xSJvFs{8)|K(DsJ+8CRAU;(K+k>^gEIu`NHhzE<#a+b$H(-O{=eM5qywH|YGw z51*9zzo%YzBnjxLDbO45|5b}5mnEKE|J%qRpC4Vfzzs_K&J|9HOy3DG29r)C0OnzB z0FX3OxgF0RN(o^ln?W~#W`!W1f$Hmei2ch)3wv8$8rr?Hqtz7Pt^H1)Z~}Xnk)fL` zAS%oS2_%fV7XUysynWz+h)?)y_^d}j1U_W32SNU9NGaZ#-_tVtYL^|w%M6}e_KWbO zGhiSz#EgXFOOGT66>~~k<2&1)`KAN7QU_$RX|6CLYS5oRS_mXU*M3rV4(wlsy4+_n z;R|%M>HxsNbG~%Jtl&!@kx*3D8p(XoE11j*Bf~Oco@q>$8 z;%TW_OExUrdu%9FMIq|>?D1WG_S8~b zZ6|^-YCw@B^k_QZNbF!J*6=&@@QdFi!*BIO^rxUi=OyR-Hrp>7zVx720su6jK^F!h zdNgkdW6|m-HvTX&EB{&vdp9rmkfpblnKjbGfTn@;2t*_X&8h>0o`K+ZvU<(;2hy|( z%&i!*beR=E1OnMi*a0>^Xr8n7Qiaj=001Dje`PJX;buTCBB9q0C{rI;9bxc3J{$Xq z-RKW-v&etC{u2fs0APVJiwJKf zR=4aKtT4Os636F9v2X9(`u4t{$ckv1sh3F@vYKziLryP=Uc9BT076H%+9 zssI2GN~Tu~JGia{g~L34wOwm${If#PvdW{;xvhuEcqL|uc)}jqMm5oj z6R&CjXm6Kd@_kLBwsznyrfCq#hLxj{xHAuv<;!CiN`+sbkv(qrR}cR80Jjl${c-va XG6xoUHST1K00000NkvXXu0mjfq}f^< literal 0 HcmV?d00001 From 36f51baf2ba37bad8c6541d7b0f8505063852581 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 8 Aug 2024 19:59:30 +0300 Subject: [PATCH 06/13] client: Fix CKEditor modal background after update (fixes #304) --- src/public/stylesheets/ckeditor-theme.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/public/stylesheets/ckeditor-theme.css b/src/public/stylesheets/ckeditor-theme.css index eac57cf47..225788c5b 100644 --- a/src/public/stylesheets/ckeditor-theme.css +++ b/src/public/stylesheets/ckeditor-theme.css @@ -4,6 +4,7 @@ body { --ck-color-base-text: var(--main-text-color); --ck-color-base-foreground: var(--accented-background-color); --ck-color-base-background: var(--main-background-color); + --ck-color-dialog-background: var(--ck-color-base-background); --ck-color-focus-border: var(--main-border-color); --ck-color-text: var(--main-text-color); --ck-color-shadow-drop: var(--main-background-color); From 513b0c65975944ed0b4350852b9b24909ca48a2a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 8 Aug 2024 23:26:58 +0300 Subject: [PATCH 07/13] ci: Remove problematic platforms for now --- .github/workflows/main-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-docker.yml b/.github/workflows/main-docker.yml index 96bffbd6e..8e09f6b00 100644 --- a/.github/workflows/main-docker.yml +++ b/.github/workflows/main-docker.yml @@ -16,7 +16,7 @@ env: DOCKERHUB_REGISTRY: docker.io IMAGE_NAME: ${{ github.repository }} TEST_TAG: triliumnext/notes:test - PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 + PLATFORMS: linux/amd64,linux/arm64 jobs: test_docker: From 676bff43d9c2d3fad9005e8fae5352bf728c41de Mon Sep 17 00:00:00 2001 From: perf3ct Date: Thu, 8 Aug 2024 14:38:39 -0700 Subject: [PATCH 08/13] fix arm builds --- .github/workflows/main-docker.yml | 257 +++++++++++++++--------------- Dockerfile | 45 ++++-- 2 files changed, 160 insertions(+), 142 deletions(-) diff --git a/.github/workflows/main-docker.yml b/.github/workflows/main-docker.yml index 96bffbd6e..398cb4c58 100644 --- a/.github/workflows/main-docker.yml +++ b/.github/workflows/main-docker.yml @@ -1,148 +1,155 @@ on: - push: - branches: - - "develop" - - "feature/update**" - - "feature/server_esm**" - paths-ignore: - - "docs/**" - - "bin/**" - tags: - - "v*" - workflow_dispatch: + push: + branches: + - "develop" + - "feature/update**" + - "feature/server_esm**" + paths-ignore: + - "docs/**" + - "bin/**" + tags: + - "v*" + workflow_dispatch: env: - GHCR_REGISTRY: ghcr.io - DOCKERHUB_REGISTRY: docker.io - IMAGE_NAME: ${{ github.repository }} - TEST_TAG: triliumnext/notes:test - PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 + GHCR_REGISTRY: ghcr.io + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: ${{ github.repository }} + TEST_TAG: triliumnext/notes:test + PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm64/v8 jobs: - test_docker: - name: Check Docker build - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4 + test_docker: + name: Check Docker build + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Set up node & dependencies - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "npm" - - - run: npm ci - - - name: Run the TypeScript build - run: npx tsc - - - name: Create server-package.json - run: cat package.json | grep -v electron > server-package.json - - - name: Build and export to Docker - uses: docker/build-push-action@v6 - with: - context: . - load: true - tags: ${{ env.TEST_TAG }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Run the container in the background - run: docker run -d --rm --name trilium_local ${{ env.TEST_TAG }} - - - name: Wait for the healthchecks to pass - uses: stringbean/docker-healthcheck-action@v1 - with: - container: trilium_local - wait-time: 50 - require-status: running - require-healthy: true - - build_docker: - name: Build Docker images - runs-on: ubuntu-latest - needs: - - test_docker - permissions: - contents: read - packages: write - attestations: write - id-token: write - steps: - - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Extract metadata (tags, labels) for GHCR image - id: ghcr-meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }} - tags: - - name: Extract metadata (tags, labels) for DockerHub image - id: dh-meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }} - name: Set up node & dependencies uses: actions/setup-node@v4 with: node-version: 20 cache: "npm" + - run: npm ci + - name: Run the TypeScript build run: npx tsc + - name: Create server-package.json run: cat package.json | grep -v electron > server-package.json - - name: Log in to the GHCR container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.GHCR_REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/setup-buildx-action@v3 - - name: Build and push container image to GHCR + + - name: Build and export to Docker uses: docker/build-push-action@v6 - id: ghcr-push with: context: . - platforms: ${{ env.PLATFORMS }} - push: true - tags: ${{ steps.ghcr-meta.outputs.tags }} - labels: ${{ steps.ghcr-meta.outputs.labels }} + load: true + tags: ${{ env.TEST_TAG }} cache-from: type=gha cache-to: type=gha,mode=max - - name: Generate and push artifact attestation to GHCR - uses: actions/attest-build-provenance@v1 + + - name: Run the container in the background + run: docker run -d --rm --name trilium_local ${{ env.TEST_TAG }} + + - name: Wait for the healthchecks to pass + uses: stringbean/docker-healthcheck-action@v1 with: - subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}} - subject-digest: ${{ steps.ghcr-push.outputs.digest }} - push-to-registry: true - - name: Log in to the DockerHub container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.DOCKERHUB_REGISTRY }} - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push image to DockerHub - uses: docker/build-push-action@v6 - id: dh-push - with: - context: . - platforms: ${{ env.PLATFORMS }} - push: true - tags: ${{ steps.dh-meta.outputs.tags }} - labels: ${{ steps.dh-meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Generate and push artifact attestation to DockerHub - uses: actions/attest-build-provenance@v1 - with: - subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}} - subject-digest: ${{ steps.dh-push.outputs.digest }} - push-to-registry: true - \ No newline at end of file + container: trilium_local + wait-time: 50 + require-status: running + require-healthy: true + + build_docker: + name: Build Docker images + runs-on: ubuntu-latest + needs: + - test_docker + permissions: + contents: read + packages: write + attestations: write + id-token: write + strategy: + matrix: + architecture: [linux/amd64, linux/arm64, linux/arm/v7, linux/arm64/v8] + steps: + - uses: actions/checkout@v4 + - name: Extract metadata (tags, labels) for GHCR image + id: ghcr-meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + - name: Extract metadata (tags, labels) for DockerHub image + id: dh-meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - run: npm ci + - name: Run the TypeScript build + run: npx tsc + - name: Create server-package.json + run: cat package.json | grep -v electron > server-package.json + - name: Log in to the GHCR container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.GHCR_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/setup-buildx-action@v3 + - name: Build and push container image to GHCR + uses: docker/build-push-action@v6 + id: ghcr-push + with: + context: . + platforms: ${{ matrix.architecture }} + push: true + tags: ${{ steps.ghcr-meta.outputs.tags }} + labels: ${{ steps.ghcr-meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + - name: Generate and push artifact attestation to GHCR + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.ghcr-push.outputs.digest }} + push-to-registry: true + - name: Log in to the DockerHub container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKERHUB_REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push image to DockerHub + uses: docker/build-push-action@v6 + id: dh-push + with: + context: . + platforms: ${{ matrix.architecture }} + push: true + tags: ${{ steps.dh-meta.outputs.tags }} + labels: ${{ steps.dh-meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + - name: Generate and push artifact attestation to DockerHub + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.dh-push.outputs.digest }} + push-to-registry: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 339f44fd3..2dc3ccef4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!! -FROM node:20.15.1-alpine +FROM node:20.15.1-bullseye-slim # Configure system dependencies -RUN apk add --no-cache --virtual .build-dependencies \ +RUN apt-get update && apt-get install -y --no-install-recommends \ autoconf \ automake \ g++ \ @@ -11,7 +11,9 @@ RUN apk add --no-cache --virtual .build-dependencies \ make \ nasm \ libpng-dev \ - python3 + python3 \ + gosu \ + && rm -rf /var/lib/apt/lists/* # Create app directory WORKDIR /usr/src/app @@ -32,24 +34,33 @@ RUN rm docker_healthcheck.ts RUN rm -r build # Install app dependencies -RUN set -x \ - && npm install \ - && apk del .build-dependencies \ - && npm run webpack \ - && npm prune --omit=dev \ - && cp src/public/app/share.js src/public/app-dist/. \ - && cp -r src/public/app/doc_notes src/public/app-dist/. \ - && rm -rf src/public/app \ - && rm src/services/asset_path.ts +RUN set -x +RUN npm install +RUN apt-get purge -y --auto-remove \ + autoconf \ + automake \ + g++ \ + gcc \ + libtool \ + make \ + nasm \ + libpng-dev \ + python3 \ + && rm -rf /var/lib/apt/lists/* +RUN npm run webpack +RUN npm prune --omit=dev +RUN cp src/public/app/share.js src/public/app-dist/. +RUN cp -r src/public/app/doc_notes src/public/app-dist/. +RUN rm -rf src/public/app +RUN rm src/services/asset_path.ts # Some setup tools need to be kept -RUN apk add --no-cache su-exec shadow - -# Add application user and setup proper volume permissions -RUN adduser -s /bin/false node; exit 0 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gosu \ + && rm -rf /var/lib/apt/lists/* # Start the application EXPOSE 8080 CMD [ "./start-docker.sh" ] -HEALTHCHECK --start-period=10s CMD exec su-exec node node docker_healthcheck.js +HEALTHCHECK --start-period=10s CMD exec gosu node node docker_healthcheck.js \ No newline at end of file From a98f01d9241483b0fd139e0d8e7dc96b8d111df0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 9 Aug 2024 00:41:55 +0300 Subject: [PATCH 09/13] integration-test: Create authentication setup --- .gitignore | 1 + integration-tests/auth.setup.ts | 17 +++++++++++++++++ .../{example.spec.ts => example.disabled.ts} | 0 .../{katex.spec.ts => katex.disabled.ts} | 8 -------- integration-tests/update_check.spec.ts | 5 +++++ playwright.config.ts | 12 ++++++++---- 6 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 integration-tests/auth.setup.ts rename integration-tests/{example.spec.ts => example.disabled.ts} (100%) rename integration-tests/{katex.spec.ts => katex.disabled.ts} (67%) create mode 100644 integration-tests/update_check.spec.ts diff --git a/.gitignore b/.gitignore index a56c97182..7d012a354 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ images/app-icons/mac/*.png /playwright-report/ /blob-report/ /playwright/.cache/ +/playwright/.auth/ \ No newline at end of file diff --git a/integration-tests/auth.setup.ts b/integration-tests/auth.setup.ts new file mode 100644 index 000000000..ba2670006 --- /dev/null +++ b/integration-tests/auth.setup.ts @@ -0,0 +1,17 @@ +import { test as setup, expect } from '@playwright/test'; + +const authFile = 'playwright/.auth/user.json'; + +const ROOT_URL = "http://localhost:8080"; +const LOGIN_PASSWORD = "eliandoran"; + +// Reference: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests + +setup("authenticate", async ({ page }) => { + await page.goto(ROOT_URL); + await expect(page).toHaveURL(`${ROOT_URL}/login`); + + await page.getByRole("textbox", { name: "Password" }).fill(LOGIN_PASSWORD); + await page.getByRole("button", { name: "Login"}).click(); + await page.context().storageState({ path: authFile }); +}); \ No newline at end of file diff --git a/integration-tests/example.spec.ts b/integration-tests/example.disabled.ts similarity index 100% rename from integration-tests/example.spec.ts rename to integration-tests/example.disabled.ts diff --git a/integration-tests/katex.spec.ts b/integration-tests/katex.disabled.ts similarity index 67% rename from integration-tests/katex.spec.ts rename to integration-tests/katex.disabled.ts index 1b6be60a5..c1ce0d9d7 100644 --- a/integration-tests/katex.spec.ts +++ b/integration-tests/katex.disabled.ts @@ -7,14 +7,6 @@ test("Can insert equations", async ({ page }) => { await page.setDefaultTimeout(60_000); await page.setDefaultNavigationTimeout(60_000); - await page.goto(ROOT_URL); - await expect(page).toHaveURL(`${ROOT_URL}/login`); - - // Log in - await page.getByRole("textbox", { name: "Password" }).fill(LOGIN_PASSWORD); - await page.getByRole("button", { name: "Login"}).click(); - await page.waitForURL(/\/#root\//); - // Create a new note // await page.locator("button.button-widget.bx-file-blank") // .click(); diff --git a/integration-tests/update_check.spec.ts b/integration-tests/update_check.spec.ts new file mode 100644 index 000000000..be0ee75b0 --- /dev/null +++ b/integration-tests/update_check.spec.ts @@ -0,0 +1,5 @@ +import { test, expect } from '@playwright/test'; + +test("Displays update badge when there is a version available", async ({ page }) => { + await page.goto("http://localhost:8080"); +}); \ No newline at end of file diff --git a/playwright.config.ts b/playwright.config.ts index 10528c325..12420d3a5 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -34,13 +34,17 @@ export default defineConfig({ /* Configure projects for major browsers */ projects: [ { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, + name: "setup", + testMatch: /.*\.setup\.ts/ }, { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, + name: "firefox", + use: { + ...devices[ "Desktop Firefox" ], + storageState: "playwright/.auth/user.json" + }, + dependencies: [ "setup" ] }, /* Test against mobile viewports. */ From 3014b11422b5226e016407c27734507c380ab9da Mon Sep 17 00:00:00 2001 From: perf3ct Date: Thu, 8 Aug 2024 14:52:09 -0700 Subject: [PATCH 10/13] swap su-exec to gosu --- start-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-docker.sh b/start-docker.sh index 823b6eba9..342e2c08a 100755 --- a/start-docker.sh +++ b/start-docker.sh @@ -4,4 +4,4 @@ [[ ! -z "${USER_GID}" ]] && groupmod -og ${USER_GID} node || echo "No USER_GID specified, leaving 1000" chown -R node:node /home/node -exec su-exec node node ./src/www +exec gosu node node ./src/www From 42058034a57b5380310fba571e1fd34f4a134ccd Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 9 Aug 2024 00:54:26 +0300 Subject: [PATCH 11/13] client: Fix redirecting to wrong URL for downloading new version (closes #313) --- integration-tests/update_check.spec.ts | 7 +++++++ src/public/app/widgets/buttons/global_menu.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/integration-tests/update_check.spec.ts b/integration-tests/update_check.spec.ts index be0ee75b0..207395296 100644 --- a/integration-tests/update_check.spec.ts +++ b/integration-tests/update_check.spec.ts @@ -1,5 +1,12 @@ import { test, expect } from '@playwright/test'; +const expectedVersion = "0.90.3"; + test("Displays update badge when there is a version available", async ({ page }) => { await page.goto("http://localhost:8080"); + await page.getByRole('button', { name: '' }).click(); + await page.getByText(`Version ${expectedVersion} is available,`).click(); + + const page1 = await page.waitForEvent('popup'); + expect(page1.url()).toBe(`https://github.com/TriliumNext/Notes/releases/tag/v${expectedVersion}`); }); \ No newline at end of file diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js index 7203cb690..ad7806f0e 100644 --- a/src/public/app/widgets/buttons/global_menu.js +++ b/src/public/app/widgets/buttons/global_menu.js @@ -337,7 +337,7 @@ export default class GlobalMenuWidget extends BasicWidget { } downloadLatestVersionCommand() { - window.open("https://github.com/zadam/trilium/releases/latest"); + window.open("https://github.com/TriliumNext/Notes/releases/latest"); } activeContextChangedEvent() { From 138b85dd3cbd3e0a68d7c3f94f4f838d00e29a8f Mon Sep 17 00:00:00 2001 From: perf3ct Date: Thu, 8 Aug 2024 15:17:02 -0700 Subject: [PATCH 12/13] change from gosu to just su --- start-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-docker.sh b/start-docker.sh index 342e2c08a..ffdcb4148 100755 --- a/start-docker.sh +++ b/start-docker.sh @@ -4,4 +4,4 @@ [[ ! -z "${USER_GID}" ]] && groupmod -og ${USER_GID} node || echo "No USER_GID specified, leaving 1000" chown -R node:node /home/node -exec gosu node node ./src/www +exec su -c "node ./src/www" node From 13ad877b2f32d15881f4f6d238622e323a52a78b Mon Sep 17 00:00:00 2001 From: perf3ct Date: Thu, 8 Aug 2024 15:17:38 -0700 Subject: [PATCH 13/13] also change the tags of build-docker.sh to triliumnext --- bin/build-docker.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/build-docker.sh b/bin/build-docker.sh index c2e921169..a765930db 100755 --- a/bin/build-docker.sh +++ b/bin/build-docker.sh @@ -10,8 +10,8 @@ cat package.json | grep -v electron > server-package.json echo "Compiling typescript..." npx tsc -sudo docker build -t triliumnext/notes:$VERSION --network host -t zadam/trilium:$SERIES . +sudo docker build -t triliumnext/notes:$VERSION --network host -t triliumnext/notes:$SERIES . if [[ $VERSION != *"beta"* ]]; then - sudo docker tag zadam/trilium:$VERSION zadam/trilium:latest + sudo docker tag triliumnext/notes:$VERSION triliumnext/notes:latest fi