Skip to content

Commit

Permalink
Build a full bundle with rollup, then minimize image size
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Jan 5, 2024
1 parent 80cf06b commit 958b5e1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions tdrive/backend/utils/nextcloud-migration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
27 changes: 17 additions & 10 deletions tdrive/backend/utils/nextcloud-migration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,41 @@
"type": "module",
"scripts": {
"build": "npm run build:clean && npm run build:ts",
"build:ts": "tsc",
"build:ts": "rollup -c",
"build:clean": "rimraf ./dist",
"clean": "npm run build:clean",
"prestart": "npm run build",
"start": "node dist/express_server.js",
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"dependencies": {},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.5",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.11",
"@types/ldapjs": "^2.2.5",
"axios": "^1.4.0",
"express": "^4.18.2",
"form-auto-content": "^3.2.1",
"formdata-node": "^6.0.3",
"jest": "^29.7.0",
"ldapjs": "^3.0.2",
"ldif": "^0.5.1",
"pino": "^8.17.1",
"pino-pretty": "^10.3.0"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.11",
"@types/ldapjs": "^2.2.5",
"jest": "^29.7.0",
"pino-pretty": "^10.3.0",
"rimraf": "^3.0.2",
"rollup": "^4.9.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^5.3.3"
}
}
22 changes: 22 additions & 0 deletions tdrive/backend/utils/nextcloud-migration/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';

export default {
input: './src/express_server.ts',
output: {
format: 'es',
dir: 'dist',
entryFileNames: '[name].js',
sourcemap: true
},
plugins: [
commonjs(),
json(),
nodeResolve({preferBuiltins: true}),
typescript(),
terser(),
]
}
3 changes: 2 additions & 1 deletion tdrive/docker/tdrive-nextcloud-migration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ WORKDIR /usr/src/app
COPY backend/utils/nextcloud-migration/src/** ./src/
COPY backend/utils/nextcloud-migration/.nvmrc ./
COPY backend/utils/nextcloud-migration/*.json ./
COPY backend/utils/nextcloud-migration/rollup.config.js ./

RUN npm i && npm run build
RUN npm i && npm run build && npm cache clean --force && rm -rf node_modules

# Don't rebuild on start
RUN perl -i -ne 'print unless/prestart/' package.json
Expand Down

0 comments on commit 958b5e1

Please sign in to comment.