mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	refactor: multistage builds (#955)
This commit is contained in:
		| @@ -7,7 +7,7 @@ services: | |||||||
|       context: ../server |       context: ../server | ||||||
|       dockerfile: Dockerfile |       dockerfile: Dockerfile | ||||||
|       target: builder |       target: builder | ||||||
|     command: npm ci && npm run test:e2e |     command: npm run test:e2e | ||||||
|     expose: |     expose: | ||||||
|       - '3000' |       - '3000' | ||||||
|     volumes: |     volumes: | ||||||
|   | |||||||
| @@ -1,5 +1,4 @@ | |||||||
|  |  | ||||||
| # Build stage |  | ||||||
| FROM node:16-bullseye-slim as builder | FROM node:16-bullseye-slim as builder | ||||||
|  |  | ||||||
| ARG DEBIAN_FRONTEND=noninteractive | ARG DEBIAN_FRONTEND=noninteractive | ||||||
| @@ -16,9 +15,14 @@ RUN npm rebuild @tensorflow/tfjs-node --build-from-source | |||||||
|  |  | ||||||
| COPY . . | COPY . . | ||||||
|  |  | ||||||
|  |  | ||||||
|  | FROM builder as prod | ||||||
|  |  | ||||||
| RUN npm run build | RUN npm run build | ||||||
|  |  | ||||||
| # Prod stage | RUN npm prune --omit=dev | ||||||
|  |  | ||||||
|  |  | ||||||
| FROM node:16-bullseye-slim | FROM node:16-bullseye-slim | ||||||
|  |  | ||||||
| ARG DEBIAN_FRONTEND=noninteractive | ARG DEBIAN_FRONTEND=noninteractive | ||||||
| @@ -29,8 +33,8 @@ RUN apt-get update \ | |||||||
|   && apt-get install -y ffmpeg \ |   && apt-get install -y ffmpeg \ | ||||||
|   && rm -rf /var/cache/apt/lists |   && rm -rf /var/cache/apt/lists | ||||||
|  |  | ||||||
| COPY --from=builder /usr/src/app/node_modules ./node_modules | COPY --from=prod /usr/src/app/node_modules ./node_modules | ||||||
| COPY --from=builder /usr/src/app/dist ./dist | COPY --from=prod /usr/src/app/dist ./dist | ||||||
|  |  | ||||||
| COPY package.json package-lock.json ./ | COPY package.json package-lock.json ./ | ||||||
| COPY entrypoint.sh ./ | COPY entrypoint.sh ./ | ||||||
|   | |||||||
| @@ -10,18 +10,22 @@ RUN npm ci | |||||||
|  |  | ||||||
| COPY . . | COPY . . | ||||||
|  |  | ||||||
| RUN npm run build |  | ||||||
|  |  | ||||||
| # Prod stage | FROM builder as prod | ||||||
|  |  | ||||||
|  | RUN npm run build | ||||||
|  | RUN npm prune --omit=dev | ||||||
|  |  | ||||||
|  |  | ||||||
| FROM node:16-alpine3.14 | FROM node:16-alpine3.14 | ||||||
|  |  | ||||||
| WORKDIR /usr/src/app | WORKDIR /usr/src/app | ||||||
|  |  | ||||||
| RUN apk add --no-cache libheif vips ffmpeg | RUN apk add --no-cache libheif vips ffmpeg | ||||||
|  |  | ||||||
| COPY --from=builder /usr/src/app/node_modules ./node_modules | COPY --from=prod /usr/src/app/node_modules ./node_modules | ||||||
| COPY --from=builder /usr/src/app/dist ./dist | COPY --from=prod /usr/src/app/dist ./dist | ||||||
| COPY --from=builder /usr/src/app/bin ./bin | COPY --from=prod /usr/src/app/bin ./bin | ||||||
|  |  | ||||||
| COPY LICENSE /licenses/LICENSE.txt | COPY LICENSE /licenses/LICENSE.txt | ||||||
| COPY LICENSE /LICENSE | COPY LICENSE /LICENSE | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user