diff --git a/.dockerignore b/.dockerignore index 7b2bb3fd..6d574b8a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,4 +4,6 @@ node_modules npm-debug.log README.md .git -.env \ No newline at end of file +.env +docker-compose.yaml +dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 621f8d93..1a42636c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,24 @@ -FROM node:18-alpine -WORKDIR / - +FROM node:18-slim AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +#Hook into pnpm without installing pnpm. (magic) (https://nodejs.org/docs/latest-v18.x/api/corepack.html) +RUN corepack enable +WORKDIR /usr/src/app COPY package*.json pnpm-lock.yaml* ./ -RUN npm i -g pnpm -RUN pnpm install +#Create node_modules files without dev dependencies. +FROM base AS prod_dependencies +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile +#Generate the dist directory. +FROM base AS builder COPY . . - +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile RUN pnpm run build -CMD pnpm run start \ No newline at end of file +#Final image +FROM base +WORKDIR /usr/src/app +COPY --from=prod_dependencies /usr/src/app/node_modules ./node_modules +COPY --from=builder /usr/src/app/dist ./dist +CMD [ "pnpm", "run", "start" ] diff --git a/package-lock.json b/package-lock.json index 1fea4cbd..69406ff1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "prom-client": "^15.0.0", "quickchart-js": "^3.1.3", "topgg-autoposter": "^2.0.1", - "uninstall": "^0.0.0", + "tslib": "^2.6.2", "uuid": "^9.0.0" }, "devDependencies": { @@ -38,7 +38,6 @@ "copyfiles": "^2.4.1", "nodemon": "3.0.1", "prettier": "^3.1.0", - "tslib": "^2.6.2", "typescript": "^5.2.2" } }, @@ -2578,11 +2577,6 @@ "node": ">=14.0" } }, - "node_modules/uninstall": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/uninstall/-/uninstall-0.0.0.tgz", - "integrity": "sha512-pjP/0+A4gsbDVa8XH/S2GZdT9NPJW8NFMy3GI7HnsWG+NAmFSSj3QidNosXBI9cPtxxNExEDdhKFO6sli8K3mA==" - }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index 353ff176..5acf0b6c 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "prom-client": "^15.0.0", "quickchart-js": "^3.1.3", "topgg-autoposter": "^2.0.1", - "uuid": "^9.0.0" + "uuid": "^9.0.0", + "tslib": "^2.6.2" }, "devDependencies": { "@types/express": "^4.17.21", @@ -63,7 +64,6 @@ "copyfiles": "^2.4.1", "nodemon": "3.0.1", "prettier": "^3.1.0", - "tslib": "^2.6.2", "typescript": "^5.2.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d256af67..2a4264ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,6 +65,9 @@ dependencies: topgg-autoposter: specifier: ^2.0.1 version: 2.0.1 + tslib: + specifier: ^2.6.2 + version: 2.6.2 uuid: specifier: ^9.0.0 version: 9.0.1 @@ -85,9 +88,6 @@ devDependencies: prettier: specifier: ^3.1.0 version: 3.1.0 - tslib: - specifier: ^2.6.2 - version: 2.6.2 typescript: specifier: ^5.2.2 version: 5.2.2 @@ -1709,6 +1709,7 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + dev: false /type-is@1.6.18: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}