diff --git a/.dockerignore b/.dockerignore index a5249c1..eebf352 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ /app/node_modules/ /app/dist/ /app/.env -/app/package-lock.json diff --git a/Dockerfile b/Dockerfile index 3747a03..5eadbe3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,24 @@ -FROM node:lts-alpine - -RUN apk --no-cache add curl - -WORKDIR /app - -COPY app/ ./ - -RUN chown -R node:node /app +FROM node:lts-alpine AS builder USER node +WORKDIR /app +COPY --chown=node:node app/ ./ -RUN npm install --omit=dev +RUN npm ci \ + && npx tsc + +FROM node:lts-alpine AS runner + +RUN apk --no-cache add curl + +USER node +WORKDIR /app +COPY --from=builder --chown=node:node app/ ./ + +RUN npm ci --omit=dev ARG PACKAGE_VERSION ENV APP_VERSION=${PACKAGE_VERSION} ENV NODE_ENV=production -# Build without type checking, as we have removed the Typescript -# dev-dependencies above to save space in the final build. -# Type checking is done in the repo before building the image. -RUN npx tsc --noCheck - CMD ["node", "dist/index.js" ] diff --git a/app/package-lock.json b/app/package-lock.json index 4bf83f7..06e93eb 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -15,8 +15,7 @@ "dotenv": "^16.4.5", "ejs": "^3.1.10", "express": "^4.21.1", - "tslib": "^2.8.1", - "typescript": "^5.6.2" + "tslib": "^2.8.1" }, "bin": { "immich-public-proxy": "dist/index.js" @@ -30,7 +29,8 @@ "@typescript-eslint/parser": "5.29.0", "eslint": "^8.49.0", "eslint-config-standard": "^17.1.0", - "ts-node": "^10.9.2" + "ts-node": "^10.9.2", + "typescript": "^5.6.2" } }, "node_modules/@cspotcode/source-map-support": { @@ -5182,6 +5182,7 @@ "version": "5.7.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/app/package.json b/app/package.json index 381252f..943eff3 100644 --- a/app/package.json +++ b/app/package.json @@ -23,8 +23,7 @@ "dotenv": "^16.4.5", "ejs": "^3.1.10", "express": "^4.21.1", - "tslib": "^2.8.1", - "typescript": "^5.6.2" + "tslib": "^2.8.1" }, "devDependencies": { "@types/archiver": "^6.0.3", @@ -35,6 +34,7 @@ "@typescript-eslint/parser": "5.29.0", "eslint": "^8.49.0", "eslint-config-standard": "^17.1.0", - "ts-node": "^10.9.2" + "ts-node": "^10.9.2", + "typescript": "^5.6.2" } }