chore(nx/docker): basic integration

This commit is contained in:
Elian Doran 2025-04-25 09:54:10 +03:00
parent 12977f145c
commit 0e8b1f31b3
No known key found for this signature in database
4 changed files with 25 additions and 26 deletions

View File

@ -23,27 +23,3 @@ RUN npm ci && \
# as we install necessary dependencies in runtime buildstage anyways
# Runtime stage
FROM node:22.14.0-alpine
# Install runtime dependencies
RUN apk add --no-cache su-exec shadow
WORKDIR /usr/src/app
COPY --from=builder /usr/src/app ./
RUN sed -i "/electron/d" package.json && \
npm ci --omit=dev && \
node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \
npm cache clean --force && \
rm -rf \
/tmp/node-compile-cache \
/usr/src/app/bin/cleanupNodeModules.ts
# Add application user
RUN adduser -s /bin/false node; exit 0
# Configure container
EXPOSE 8080
CMD [ "./start-docker.sh" ]
HEALTHCHECK --start-period=10s CMD exec su-exec node node docker_healthcheck.js

17
apps/server/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM node:22.14.0-alpine
# Install runtime dependencies
RUN apk add --no-cache su-exec shadow
WORKDIR /usr/src/app
COPY /apps/server/dist /usr/src/app
COPY /apps/server/start-docker.sh /usr/src/app
# Add application user
RUN adduser -s /bin/false node; exit 0
# Configure container
EXPOSE 8080
CMD [ "sh", "./start-docker.sh" ]
HEALTHCHECK --start-period=10s CMD exec su-exec node node docker_healthcheck.js

View File

@ -152,6 +152,12 @@
]
}
]
},
"docker-build": {
"dependsOn": [
"build"
],
"command": "docker build -f apps/server/Dockerfile . -t triliumnext"
}
}
}

View File

@ -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 -c "node ./src/main" node
exec su -c "node ./main" node