Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/improved_p…
Browse files Browse the repository at this point in the history
…romoted_attributes

; Conflicts:
;	src/public/app/layouts/desktop_layout.js
  • Loading branch information
eliandoran committed Nov 12, 2024
2 parents 4032135 + 693bcfb commit 8c5d5e3
Show file tree
Hide file tree
Showing 78 changed files with 3,995 additions and 502 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/main-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ jobs:
type=ref,event=branch
type=ref,event=tag
type=sha
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -213,7 +215,9 @@ jobs:
images: |
${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
- name: Login to GHCR
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -246,13 +250,27 @@ jobs:
# If the ref is a tag, also tag the image as stable as this is part of a 'release'
# and only go in the `if` if there is NOT a `-` in the tag's name, due to tagging of `-alpha`, `-beta`, etc...
if [[ "${GITHUB_REF}" == refs/tags/* && ! "${REF_NAME}" =~ - ]]; then
# First create stable tags
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
-t ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:stable \
$(printf '${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
-t ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:stable \
$(printf '${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
# Small delay to ensure stable tag is fully propagated
sleep 5
# Now update latest tags
docker buildx imagetools create \
-t ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:stable
docker buildx imagetools create \
-t ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:stable
fi
- name: Inspect image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Update build info
run: npm run update-build-info
run: npm run update-build-info
- name: Run electron-forge
run: npm run make-electron -- --arch=${{ matrix.arch }}
- name: Prepare artifacts (Unix)
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
run: npm ci
- name: Update build info
run: npm run update-build-info
- name: Update nightly version
run: npm run ci-update-nightly-version
- name: Run electron-forge
run: npm run make-electron -- --arch=${{ matrix.arch }}
- name: Prepare artifacts (Unix)
Expand Down Expand Up @@ -103,6 +105,7 @@ jobs:
- name: Run Linux server build (x86_64)
run: |
npm run update-build-info
npm run ci-update-nightly-version
./bin/build-server.sh
- name: Prepare artifacts
if: runner.os != 'windows'
Expand Down
63 changes: 33 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!!
FROM node:20.15.1-bullseye-slim
# Build stage
FROM node:20.15.1-bullseye-slim AS builder

# Configure system dependencies
# Configure build dependencies in a single layer
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
Expand All @@ -12,49 +12,52 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
nasm \
libpng-dev \
python3 \
gosu \
&& rm -rf /var/lib/apt/lists/*

# Create app directory
WORKDIR /usr/src/app

# Bundle app source
# Copy only necessary files for build
COPY . .
COPY server-package.json package.json

# Copy TypeScript build artifacts into the original directory structure.
# Copy the healthcheck
# Build and cleanup in a single layer
RUN cp -R build/src/* src/. && \
cp build/docker_healthcheck.js . && \
rm -r build && \
rm docker_healthcheck.ts

# Install app dependencies
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 install && \
rm docker_healthcheck.ts && \
npm install && \
npm run webpack && \
npm prune --omit=dev
RUN cp src/public/app/share.js src/public/app-dist/. && \
npm prune --omit=dev && \
npm cache clean --force && \
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
rm -rf src/public/app && \
rm src/services/asset_path.ts

# Runtime stage
FROM node:20.15.1-bullseye-slim

# Some setup tools need to be kept
# Install only runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gosu \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/*

WORKDIR /usr/src/app

# Start the application
# Copy only necessary files from builder
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/src ./src
COPY --from=builder /usr/src/app/db ./db
COPY --from=builder /usr/src/app/docker_healthcheck.js .
COPY --from=builder /usr/src/app/start-docker.sh .
COPY --from=builder /usr/src/app/package.json .
COPY --from=builder /usr/src/app/config-sample.ini .
COPY --from=builder /usr/src/app/images ./images
COPY --from=builder /usr/src/app/translations ./translations
COPY --from=builder /usr/src/app/libraries ./libraries

# Configure container
EXPOSE 8080
CMD [ "./start-docker.sh" ]

HEALTHCHECK --start-period=10s CMD exec gosu node node docker_healthcheck.js
47 changes: 28 additions & 19 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!!
FROM node:20.15.1-alpine
# Build stage
FROM node:20.15.1-alpine AS builder

# Configure system dependencies
# Configure build dependencies
RUN apk add --no-cache --virtual .build-dependencies \
autoconf \
automake \
Expand All @@ -11,43 +11,52 @@ RUN apk add --no-cache --virtual .build-dependencies \
make \
nasm \
libpng-dev \
python3
python3

# Create app directory
WORKDIR /usr/src/app

# Bundle app source
# Copy only necessary files for build
COPY . .

COPY server-package.json package.json

# Copy TypeScript build artifacts into the original directory structure.
# Copy the healthcheck
# Build and cleanup in a single layer
RUN cp -R build/src/* src/. && \
cp build/docker_healthcheck.js . && \
rm -r build && \
rm docker_healthcheck.ts

# Install app dependencies
RUN set -x && \
rm docker_healthcheck.ts && \
npm install && \
apk del .build-dependencies && \
npm run webpack && \
npm prune --omit=dev && \
npm cache clean --force && \
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

# Runtime stage
FROM node:20.15.1-alpine

# Some setup tools need to be kept
# Install runtime dependencies
RUN apk add --no-cache su-exec shadow

# Add application user and setup proper volume permissions
WORKDIR /usr/src/app

# Copy only necessary files from builder
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/src ./src
COPY --from=builder /usr/src/app/db ./db
COPY --from=builder /usr/src/app/docker_healthcheck.js .
COPY --from=builder /usr/src/app/start-docker.sh .
COPY --from=builder /usr/src/app/package.json .
COPY --from=builder /usr/src/app/config-sample.ini .
COPY --from=builder /usr/src/app/images ./images
COPY --from=builder /usr/src/app/translations ./translations
COPY --from=builder /usr/src/app/libraries ./libraries

# Add application user
RUN adduser -s /bin/false node; exit 0

# Start the application
# Configure container
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 su-exec node node docker_healthcheck.js
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ See [screenshots](https://triliumnext.github.io/Docs/Wiki/screenshot-tour) for q

There are no special migration steps to migrate from a zadam/Trilium instance to a TriliumNext/Notes instance. Just upgrade your Trilium instance to the latest version and [install TriliumNext/Notes as usual](#-installation)

Versions up to and including [v0.90.4](https://github.com/TriliumNext/Notes/releases/tag/v0.90.4) are compatible with the latest zadam/trilium version of [v0.63.7](https://github.com/zadam/trilium/releases/tag/v0.63.7). Any later versions of TriliumNext have their sync versions incremented.

## 💬 Discuss with us

Feel free to join our official conversations. We would love to hear what features, suggestions, or issues you may have!
Expand Down Expand Up @@ -65,6 +67,16 @@ To use TriliumNext on your desktop machine (Linux, MacOS, and Windows) you have
* Currently only the latest versions of Chrome & Firefox are supported (and tested).
* (Coming Soon) TriliumNext will also be provided as a Flatpak

#### MacOS
Currently when running TriliumNext/Notes on MacOS, you may get the following error:
> Apple could not verify "TriliumNext Notes" is free of malware and may harm your Mac or compromise your privacy.
You will need to run the command on your shell to resolve the error (documented [here](https://github.com/TriliumNext/Notes/issues/329#issuecomment-2287164137)):

```bash
xattr -c "/path/to/Trilium Next.app"
```

### Mobile

To use TriliumNext on a mobile device:
Expand Down
14 changes: 13 additions & 1 deletion bin/copy-dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ const copy = async () => {
await fs.copy(dir, path.join(DEST_DIR_SRC, path.basename(dir)));
}

/**
* Directories to be copied relative to the project root into <resource_dir>/src/public/app-dist.
*/
const publicDirsToCopy = [ "./src/public/app/doc_notes" ];
const PUBLIC_DIR = path.join(DEST_DIR, "src", "public", "app-dist");
for (const dir of publicDirsToCopy) {
await fs.copy(dir, path.join(PUBLIC_DIR, path.basename(dir)));
}

const nodeModulesFile = [
"node_modules/react/umd/react.production.min.js",
"node_modules/react/umd/react.development.js",
Expand All @@ -55,6 +64,7 @@ const copy = async () => {
"node_modules/katex/dist/katex.min.js",
"node_modules/katex/dist/contrib/mhchem.min.js",
"node_modules/katex/dist/contrib/auto-render.min.js",
"node_modules/@highlightjs/cdn-assets/highlight.min.js"
];

for (const file of nodeModulesFile) {
Expand Down Expand Up @@ -89,7 +99,9 @@ const copy = async () => {
"node_modules/codemirror/addon/",
"node_modules/codemirror/mode/",
"node_modules/codemirror/keymap/",
"node_modules/mind-elixir/dist/"
"node_modules/mind-elixir/dist/",
"node_modules/@highlightjs/cdn-assets/languages",
"node_modules/@highlightjs/cdn-assets/styles"
];

for (const folder of nodeModulesFolder) {
Expand Down
50 changes: 50 additions & 0 deletions bin/update-nightly-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @module
*
* The nightly version works uses the version described in `package.json`, just like any release.
* The problem with this approach is that production builds have a very aggressive cache, and
* usually running the nightly with this cached version of the application will mean that the
* user might run into module not found errors or styling errors caused by an old cache.
*
* This script is supposed to be run in the CI, which will update locally the version field of
* `package.json` to contain the date. For example, `0.90.9-beta` will become `0.90.9-test-YYMMDD-HHMMSS`.
*
*/

import { fileURLToPath } from "url";
import { dirname, join } from "path";
import fs from "fs";

function processVersion(version) {
// Remove the beta suffix if any.
version = version.replace("-beta", "");

// Add the nightly suffix, plus the date.
const referenceDate = new Date()
.toISOString()
.substring(2, 19)
.replace(/[-:]*/g, "")
.replace("T", "-");
version = `${version}-test-${referenceDate}`;

return version;
}

function main() {
const scriptDir = dirname(fileURLToPath(import.meta.url));
const packageJsonPath = join(scriptDir, "..", "package.json");

// Read the version from package.json and process it.
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
const currentVersion = packageJson.version;
const adjustedVersion = processVersion(currentVersion);
console.log("Current version is", currentVersion);
console.log("Adjusted version is", adjustedVersion);

// Write the adjusted version back in.
packageJson.version = adjustedVersion;
const formattedJson = JSON.stringify(packageJson, null, 4);
fs.writeFileSync(packageJsonPath, formattedJson);
}

main();
Binary file modified db/demo.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion forge.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = {
...getExtraResourcesForPlatform(),

// Moved to resources (TriliumNext Notes.app/Contents/Resources on macOS)
"translations/"
"translations/",
"node_modules/@highlightjs/cdn-assets/styles"
],
afterComplete: [(buildPath, _electronVersion, platform, _arch, callback) => {
const extraResources = getExtraResourcesForPlatform();
Expand Down
11 changes: 7 additions & 4 deletions libraries/ckeditor/ckeditor-content.css
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,19 @@
/* @ckeditor/ckeditor5-code-block/theme/codeblock.css */
.ck-content pre {
padding: 1em;
color: hsl(0, 0%, 20.8%);
background: hsla(0, 0%, 78%, 0.3);
border: 1px solid hsl(0, 0%, 77%);
border-radius: 2px;
text-align: left;
direction: ltr;
tab-size: 4;
white-space: pre-wrap;
font-style: normal;
min-width: 200px;
border: 0px;
border-radius: 6px;
box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.2);
}
.ck-content pre:not(.hljs) {
color: hsl(0, 0%, 20.8%);
background: hsla(0, 0%, 78%, 0.3);
}
/* @ckeditor/ckeditor5-code-block/theme/codeblock.css */
.ck-content pre code {
Expand Down
Loading

0 comments on commit 8c5d5e3

Please sign in to comment.