Nextcloud migration:: add security tips + reduce size (#307)
* Add security tips * Don't rebuild on start * Build a full bundle with rollup, then minimize image size
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
dist/
|
||||||
@@ -5,8 +5,9 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:clean && npm run build:ts",
|
"build": "npm run build:clean && npm run build:ts",
|
||||||
"build:ts": "tsc",
|
"build:ts": "rollup -c",
|
||||||
"build:clean": "rimraf ./dist",
|
"build:clean": "rimraf ./dist",
|
||||||
|
"clean": "npm run build:clean",
|
||||||
"prestart": "npm run build",
|
"prestart": "npm run build",
|
||||||
"start": "node dist/express_server.js",
|
"start": "node dist/express_server.js",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
@@ -14,25 +15,31 @@
|
|||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"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",
|
"axios": "^1.4.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"form-auto-content": "^3.2.1",
|
"form-auto-content": "^3.2.1",
|
||||||
"formdata-node": "^6.0.3",
|
"formdata-node": "^6.0.3",
|
||||||
|
"jest": "^29.7.0",
|
||||||
"ldapjs": "^3.0.2",
|
"ldapjs": "^3.0.2",
|
||||||
"ldif": "^0.5.1",
|
"ldif": "^0.5.1",
|
||||||
"pino": "^8.17.1",
|
"pino": "^8.17.1",
|
||||||
"pino-pretty": "^10.3.0"
|
"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",
|
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
"rollup": "^4.9.3",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.1",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
|
"tslib": "^2.6.2",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(),
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
# Use an official Node.js runtime as the base image
|
# Use an official Node.js runtime as the base image
|
||||||
FROM node:bullseye
|
FROM node:bullseye
|
||||||
|
|
||||||
|
run apt update && apt -y dist-upgrade
|
||||||
|
RUN apt install dirmngr
|
||||||
|
|
||||||
RUN echo "deb http://ppa.launchpad.net/nextcloud-devs/client/ubuntu zesty main" >> /etc/apt/sources.list.d/nextcloud-client.list
|
RUN echo "deb http://ppa.launchpad.net/nextcloud-devs/client/ubuntu zesty main" >> /etc/apt/sources.list.d/nextcloud-client.list
|
||||||
RUN echo "deb-src http://ppa.launchpad.net/nextcloud-devs/client/ubuntu zesty main" >> /etc/apt/sources.list.d/nextcloud-client.list
|
RUN echo "deb-src http://ppa.launchpad.net/nextcloud-devs/client/ubuntu zesty main" >> /etc/apt/sources.list.d/nextcloud-client.list
|
||||||
|
|
||||||
RUN apt install dirmngr
|
|
||||||
RUN apt-key adv --recv-key --keyserver keyserver.ubuntu.com AD3DD469
|
RUN apt-key adv --recv-key --keyserver keyserver.ubuntu.com AD3DD469
|
||||||
|
|
||||||
RUN apt update
|
RUN apt update
|
||||||
@@ -13,6 +15,8 @@ RUN apt install --assume-yes nextcloud-desktop-cmd
|
|||||||
|
|
||||||
RUN apt install ldap-utils
|
RUN apt install ldap-utils
|
||||||
|
|
||||||
|
RUN apt autoremove && apt clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set the working directory inside the container
|
# Set the working directory inside the container
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
@@ -20,8 +24,12 @@ WORKDIR /usr/src/app
|
|||||||
COPY backend/utils/nextcloud-migration/src/** ./src/
|
COPY backend/utils/nextcloud-migration/src/** ./src/
|
||||||
COPY backend/utils/nextcloud-migration/.nvmrc ./
|
COPY backend/utils/nextcloud-migration/.nvmrc ./
|
||||||
COPY backend/utils/nextcloud-migration/*.json ./
|
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
|
||||||
|
|
||||||
# Run the Node.js application
|
# Run the Node.js application
|
||||||
CMD ["npm", "run", "start"]
|
CMD ["npm", "run", "start"]
|
||||||
|
|||||||
Reference in New Issue
Block a user