mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 21:19:01 +01:00 
			
		
		
		
	this is necessary, since for Docker and electron-forge, we need to run this as an extra step after copy-dist for electron-forge: after it is done with its own "pruning", as we otherwise would need to also take care of certain electron related pruning for Docker: as a last step in the build stage
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
# Build stage
 | 
						|
FROM node:22.14.0-alpine AS builder
 | 
						|
 | 
						|
WORKDIR /usr/src/app/build
 | 
						|
 | 
						|
# Copy only necessary files for build
 | 
						|
COPY . .
 | 
						|
 | 
						|
# Build and cleanup in a single layer
 | 
						|
RUN npm ci && \
 | 
						|
    npm run build:prepare-dist && \
 | 
						|
    npm cache clean --force && \
 | 
						|
    rm -rf build/node_modules && \
 | 
						|
    mv build/* \
 | 
						|
      start-docker.sh \
 | 
						|
      /usr/src/app/ && \
 | 
						|
    rm -rf \
 | 
						|
      /usr/src/app/build \
 | 
						|
      /tmp/node-compile-cache
 | 
						|
 | 
						|
#TODO: run cleanupNodeModules script
 | 
						|
#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
 | 
						|
 | 
						|
# 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 && \
 | 
						|
    npm cache clean --force && \
 | 
						|
    rm -rf /tmp/node-compile-cache
 | 
						|
 | 
						|
# 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 |