make docker image smaller

This commit is contained in:
2023-01-15 12:38:21 +01:00
parent cd9f3f9cc4
commit 3b97652c02
5 changed files with 776 additions and 283 deletions

View File

@@ -3,3 +3,4 @@ npm-debug.log
frontend/node_modules frontend/node_modules
frontend/npm-debug.log frontend/npm-debug.log
frontend/.parcel-cache

View File

@@ -1,21 +1,25 @@
# might fix this? https://github.com/parcel-bundler/parcel/issues/6735 # might fix this? https://github.com/parcel-bundler/parcel/issues/6735
FROM node:16-bullseye FROM node:16-bullseye as frontbuild
WORKDIR /usr/src/app/frontend
COPY ./frontend/package*.json ./
RUN npm ci --only=production
COPY ./ ../
RUN npm run build && bash -O extglob -c 'rm -rfv !("dist")'
WORKDIR ../
RUN bash -O extglob -c 'rm -rfv !("frontend")'
FROM node:16-alpine as backexceptwithoutfrontend
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
COPY ./ ./
RUN rm -rfv frontend
RUN mkdir frontend FROM backexceptwithoutfrontend
WORKDIR frontend
COPY ./frontend/package*.json ./
RUN npm ci --only=production
WORKDIR ../
COPY . . COPY --from=frontbuild /usr/src/app/frontend .
WORKDIR frontend
RUN npm run build
WORKDIR ../
#ENV PORT=8080 #ENV PORT=8080
#ENV TYPEORM_HOST=localhost #ENV TYPEORM_HOST=localhost

987
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -24,23 +24,10 @@
"dependencies": { "dependencies": {
"@koa/cors": "^3.4.1", "@koa/cors": "^3.4.1",
"@koa/router": "^12.0.0", "@koa/router": "^12.0.0",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"bcrypt": "^5.1.0", "bcrypt": "^5.1.0",
"chai": "^4.3.7",
"class-validator": "^0.14.0", "class-validator": "^0.14.0",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"deasync": "^0.1.28",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.4",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-prettier": "^4.2.1",
"exifreader": "^4.9.1", "exifreader": "^4.9.1",
"hasha": "^5.2.2", "hasha": "^5.2.2",
"husky": "^8.0.3",
"jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.0",
"koa": "^2.14.1", "koa": "^2.14.1",
"koa-body": "^5.0.0", "koa-body": "^5.0.0",
@@ -50,14 +37,9 @@
"koa-sslify": "^5.0.1", "koa-sslify": "^5.0.1",
"koa-static": "^5.0.0", "koa-static": "^5.0.0",
"mime-types": "^2.1.35", "mime-types": "^2.1.35",
"mocha": "^10.2.0",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"prettier": "^2.8.2",
"prettier-eslint": "^15.0.1",
"sharp": "^0.31.3", "sharp": "^0.31.3",
"supertest": "^6.3.3",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"ts-node-dev": "^2",
"tsconfig-paths": "^4.1.2", "tsconfig-paths": "^4.1.2",
"typeorm": "^0.2.41", "typeorm": "^0.2.41",
"typescript": "^4.9.4" "typescript": "^4.9.4"
@@ -83,8 +65,25 @@
"@types/prettier": "^2.7.2", "@types/prettier": "^2.7.2",
"@types/sharp": "^0.31.1", "@types/sharp": "^0.31.1",
"@types/supertest": "^2.0.12", "@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"chai": "^4.3.7",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.4",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.0", "mocha-junit-reporter": "^2.2.0",
"mocha-multi-reporters": "^1.5.1" "mocha-multi-reporters": "^1.5.1",
"prettier": "^2.8.2",
"prettier-eslint": "^15.0.1",
"supertest": "^6.3.3",
"ts-node-dev": "^2"
}, },
"husky": { "husky": {
"hooks": { "hooks": {

View File

@@ -1,4 +1,3 @@
import deasync = require("deasync");
import { fromFile } from "hasha"; import { fromFile } from "hasha";
import * as ExifReader from "exifreader"; import * as ExifReader from "exifreader";
import * as sharp from "sharp"; import * as sharp from "sharp";
@@ -71,9 +70,4 @@ export async function fileCheck(file: string) {
} catch (e) { } catch (e) {
return false; return false;
} }
} }
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const getHashSync: (file: string) => string = deasync(getHash);
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const getSizeSync: (file: string) => string = deasync(getSize);