Skip to content

Commit

Permalink
Merge branch 'develop' into chore_eslint-fixes_src-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
pano9000 authored Mar 8, 2025
2 parents ecf1a0e + 4cffc50 commit c120132
Show file tree
Hide file tree
Showing 196 changed files with 2,158 additions and 115,279 deletions.
39 changes: 33 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
.git
.idea
# ignored Files
.dockerignore
.editorconfig
.git*
.prettier*
electron*
entitlements.plist
forge.config.cjs
nodemon.json
renovate.json
trilium.iml
Dockerfile
Dockerfile.*
npm-debug.log
/src/**/*.spec.ts

# ignored folders
/.cache
/.git
/.github
/.idea
/.vscode
/bin
/build
/dist
/docs
/npm-debug.log
node_modules
/dump-db
/e2e
/integration-tests
/spec
/test
/test-etapi
/node_modules


src/**/*.ts
!src/services/asset_path.ts
# exceptions
!/bin/copy-dist.ts
24 changes: 0 additions & 24 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ jobs:
- test_dev
steps:
- uses: actions/checkout@v4
- 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
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
Expand Down Expand Up @@ -82,20 +72,6 @@ jobs:
- 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:
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/main-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ jobs:
- 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:
Expand Down Expand Up @@ -154,18 +151,6 @@ jobs:
- 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: Login to GHCR
uses: docker/login-action@v3
with:
Expand Down
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"recommendations": ["lokalise.i18n-ally", "editorconfig.editorconfig"]
"recommendations": [
"lokalise.i18n-ally",
"editorconfig.editorconfig",
"vitest.explorer"
]
}
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"name": "nodemon server:start",
"program": "${workspaceFolder}/src/main",
"name": "nodemon start-server",
"program": "${workspaceFolder}/src/www",
"request": "launch",
"restart": true,
"runtimeExecutable": "nodemon",
Expand Down
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@
"[css]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"npm.exclude": ["**/build", "**/dist", "**/out/**"]
"npm.exclude": [
"**/build",
"**/dist",
"**/out/**"
],
"[xml]": {
"editor.defaultFormatter": "redhat.vscode-xml"
}
}
70 changes: 27 additions & 43 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,46 @@
# Build stage
FROM node:22.14.0-bullseye-slim AS builder

# Configure build dependencies in a single layer
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
g++ \
gcc \
libtool \
make \
nasm \
libpng-dev \
python3 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app
WORKDIR /usr/src/app/build

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

# Build and cleanup in a single layer
RUN cp -R build/src/* src/. && \
cp build/docker_healthcheck.js . && \
rm docker_healthcheck.ts && \
npm install && \
npm run build:webpack && \
npm prune --omit=dev && \
RUN npm ci && \
npm run build:prepare-dist && \
npm cache clean --force && \
cp -r src/public/app/doc_notes src/public/app-dist/. && \
rm -rf src/public/app/* && \
mkdir -p src/public/app/services && \
cp -r build/src/public/app/services/mime_type_definitions.js src/public/app/services/mime_type_definitions.js && \
rm src/services/asset_path.ts && \
rm -r build
rm -rf dist/node_modules && \
mv dist/* \
start-docker.sh \
/usr/src/app/ && \
rm -rf \
/usr/src/app/build \
/tmp/node-compile-cache

#TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work
# currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down),
# as we install necessary dependencies in runtime buildstage anyways

# Runtime stage
FROM node:22.14.0-bullseye-slim

WORKDIR /usr/src/app

# 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/cache/apt/*
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gosu && \
rm -rf \
/var/lib/apt/lists/* \
/var/cache/apt/*

WORKDIR /usr/src/app
COPY --from=builder /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
RUN sed -i "/electron/d" package.json && \
npm ci --omit=dev && \
npm cache clean --force && \
rm -rf /tmp/node-compile-cache

# Configure container
EXPOSE 8080
Expand Down
57 changes: 20 additions & 37 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
# Build stage
FROM node:22.14.0-alpine AS builder

# Configure build dependencies
RUN apk add --no-cache --virtual .build-dependencies \
autoconf \
automake \
g++ \
gcc \
libtool \
make \
nasm \
libpng-dev \
python3

WORKDIR /usr/src/app
WORKDIR /usr/src/app/build

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

# Build and cleanup in a single layer
RUN cp -R build/src/* src/. && \
cp build/docker_healthcheck.js . && \
rm docker_healthcheck.ts && \
npm install && \
npm run build:webpack && \
npm prune --omit=dev && \
RUN npm ci && \
npm run build:prepare-dist && \
npm cache clean --force && \
cp -r src/public/app/doc_notes src/public/app-dist/. && \
rm -rf src/public/app && \
mkdir -p src/public/app/services && \
cp -r build/src/public/app/services/mime_type_definitions.js src/public/app/services/mime_type_definitions.js && \
rm src/services/asset_path.ts && \
rm -r build
rm -rf dist/node_modules && \
mv dist/* \
start-docker.sh \
/usr/src/app/ && \
rm -rf \
/usr/src/app/build \
/tmp/node-compile-cache

#TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work
# currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down),
# as we install necessary dependencies in runtime buildstage anyways

# Runtime stage
FROM node:22.14.0-alpine
Expand All @@ -42,17 +30,12 @@ RUN apk add --no-cache su-exec shadow

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
COPY --from=builder /usr/src/app ./

RUN sed -i "/electron/d" package.json && \
npm ci --omit=dev && \
npm cache clean --force && \
rm -rf /tmp/node-compile-cache

# Add application user
RUN adduser -s /bin/false node; exit 0
Expand Down
5 changes: 0 additions & 5 deletions bin/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ set -e # Fail on any command error
VERSION=`jq -r ".version" package.json`
SERIES=${VERSION:0:4}-latest

cat package.json | grep -v electron > server-package.json

echo "Compiling typescript..."
npx tsc

sudo docker build -t triliumnext/notes:$VERSION --network host -t triliumnext/notes:$SERIES .

if [[ $VERSION != *"beta"* ]]; then
Expand Down
Loading

0 comments on commit c120132

Please sign in to comment.