WIP
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
FROM node:lts-alpine AS builder
|
||||
|
||||
# /ipp must be node-owned for npm ci; WORKDIR leaves it root-owned on some builders
|
||||
RUN mkdir /ipp && chown node:node /ipp
|
||||
|
||||
USER node
|
||||
WORKDIR /ipp
|
||||
|
||||
# npm ci needs the manifest of every workspace in the root `workspaces` array
|
||||
COPY --chown=node:node package.json package-lock.json ./
|
||||
COPY --chown=node:node shared/package.json shared/
|
||||
COPY --chown=node:node app/package.json app/
|
||||
COPY --chown=node:node upload-app/package.json upload-app/
|
||||
RUN npm ci --workspace=upload-app
|
||||
|
||||
COPY --chown=node:node shared/ shared/
|
||||
COPY --chown=node:node upload-app/ upload-app/
|
||||
RUN npm run build --workspace=shared --workspace=upload-app
|
||||
|
||||
# Production tree with @ipp/core dereferenced from its workspace symlink into a
|
||||
# real folder (cp -L), so the runner's /app is self-contained. The apps'
|
||||
# workspace links go first: the runner has the upload app at /app, and IPP
|
||||
# has no place in this image.
|
||||
RUN rm -rf node_modules \
|
||||
&& npm ci --workspace=upload-app --omit=dev \
|
||||
&& rm -rf node_modules/immich-public-proxy node_modules/immich-public-proxy-upload node_modules/.bin/immich-public-proxy* \
|
||||
&& cp -rL node_modules /ipp/prod_modules \
|
||||
&& cd /ipp/prod_modules/@ipp/core \
|
||||
&& rm -rf src tests tsconfig.json vitest.config.ts dist/tsconfig.tsbuildinfo \
|
||||
&& rm -f /ipp/upload-app/dist/tsconfig.tsbuildinfo
|
||||
|
||||
FROM node:lts-alpine AS runner
|
||||
|
||||
RUN apk --no-cache add curl \
|
||||
&& mkdir /app && chown node:node /app
|
||||
|
||||
# At /app, as IPP, so a config.json mounts at the same path in both images
|
||||
USER node
|
||||
WORKDIR /app
|
||||
COPY --from=builder --chown=node:node /ipp/upload-app/package.json ./
|
||||
COPY --from=builder --chown=node:node /ipp/prod_modules ./node_modules
|
||||
COPY --from=builder --chown=node:node /ipp/upload-app/dist ./dist
|
||||
COPY --from=builder --chown=node:node /ipp/upload-app/public ./public
|
||||
COPY --from=builder --chown=node:node /ipp/upload-app/config.json ./
|
||||
|
||||
ARG PACKAGE_VERSION
|
||||
ENV APP_VERSION=${PACKAGE_VERSION}
|
||||
ENV NODE_ENV=production
|
||||
|
||||
CMD ["node", "dist/index.js" ]
|
||||
Reference in New Issue
Block a user