mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:26:08 +08:00 
			
		
		
		
	chore(docker): integrate debian-based container
This commit is contained in:
		
							parent
							
								
									fada21027e
								
							
						
					
					
						commit
						dd99f6c918
					
				
					 4 changed files with 48 additions and 13 deletions
				
			
		|  | @ -1,7 +1,6 @@ | |||
| # Build stage | ||||
| FROM node:22.14.0-bullseye-slim AS builder | ||||
| 
 | ||||
| WORKDIR /usr/src/app/build | ||||
| 
 | ||||
| 
 | ||||
| # Copy only necessary files for build | ||||
| COPY . . | ||||
|  |  | |||
|  | @ -1,14 +1,19 @@ | |||
| FROM node:22.14.0-alpine AS builder | ||||
| FROM node:22.14.0-bullseye-slim AS builder | ||||
|     RUN corepack enable | ||||
| 
 | ||||
|     # Install native dependencies since we might be building cross-platform. | ||||
|     WORKDIR /usr/src/app | ||||
|     WORKDIR /usr/src/app/build | ||||
|     COPY ./dist/package.json ./dist/pnpm-lock.yaml /usr/src/app/ | ||||
|     RUN pnpm install --frozen-lockfile --prod && pnpm rebuild | ||||
| 
 | ||||
| FROM node:22.14.0-alpine | ||||
|     # Install runtime dependencies | ||||
|     RUN apk add --no-cache su-exec shadow | ||||
| FROM node:22.14.0-bullseye-slim | ||||
|     # Install only runtime dependencies | ||||
|     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 ./dist /usr/src/app | ||||
|  | @ -16,10 +21,7 @@ FROM node:22.14.0-alpine | |||
|     COPY --from=builder /usr/src/app/node_modules/better-sqlite3 /usr/src/app/node_modules/better-sqlite3 | ||||
|     COPY ./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 | ||||
|     CMD [ "./start-docker.sh" ] | ||||
|     HEALTHCHECK --start-period=10s CMD exec gosu node node docker_healthcheck.js | ||||
							
								
								
									
										25
									
								
								apps/server/Dockerfile.alpine
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								apps/server/Dockerfile.alpine
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | |||
| FROM node:22.14.0-alpine AS builder | ||||
|     RUN corepack enable | ||||
| 
 | ||||
|     # Install native dependencies since we might be building cross-platform. | ||||
|     WORKDIR /usr/src/app | ||||
|     COPY ./dist/package.json ./dist/pnpm-lock.yaml /usr/src/app/ | ||||
|     RUN pnpm install --frozen-lockfile --prod && pnpm rebuild | ||||
| 
 | ||||
| FROM node:22.14.0-alpine | ||||
|     # Install runtime dependencies | ||||
|     RUN apk add --no-cache su-exec shadow | ||||
| 
 | ||||
|     WORKDIR /usr/src/app | ||||
|     COPY ./dist /usr/src/app | ||||
|     RUN rm -rf /usr/src/app/node_modules/better-sqlite3 | ||||
|     COPY --from=builder /usr/src/app/node_modules/better-sqlite3 /usr/src/app/node_modules/better-sqlite3 | ||||
|     COPY ./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 | ||||
|  | @ -159,9 +159,18 @@ | |||
|         "dependsOn": [ | ||||
|           "build" | ||||
|         ], | ||||
|         "command": "docker build . -t triliumnext", | ||||
|         "options": { | ||||
|           "cwd": "{projectRoot}" | ||||
|         }, | ||||
|         "executor": "nx:run-commands", | ||||
|         "defaultConfiguration": "alpine", | ||||
|         "configurations": { | ||||
|           "debian": { | ||||
|             "command": "docker build . -t triliumnext -f Dockerfile" | ||||
|           }, | ||||
|           "alpine": { | ||||
|             "command": "docker build . -t triliumnext -f Dockerfile.alpine" | ||||
|           } | ||||
|         } | ||||
|       }, | ||||
|       "docker-start": { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue