Containerise socket server

See https://github.com/excalidraw/excalidraw/issues/1772#issuecomment-652043326
This commit is contained in:
Minh Nguyen 2020-07-14 10:57:34 +01:00
parent 30ca342490
commit 0e1c9cb583
4 changed files with 29 additions and 2 deletions

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM node:14-alpine
WORKDIR /excalidraw-room
COPY package.json yarn.lock ./
COPY scripts ./scripts
RUN SKIP_YARN_POSTINSTALL=true yarn
COPY tsconfig.json ./
COPY src ./src
RUN yarn build
EXPOSE 80
CMD ["yarn", "start"]

View File

@ -7,7 +7,7 @@
"build": "tsc",
"fix": "yarn prettier --write",
"lint": "yarn prettier --list-different",
"postinstall": "npm run build",
"postinstall": "node scripts/postinstall.js",
"prettier": "prettier \"**/*.{ts,md,json,yaml,yml}\"",
"start": "node dist/index.js",
"test": "yarn lint"
@ -40,6 +40,9 @@
"typescript": "3.9.5"
},
"eslintConfig": {
"env": {
"es6": true
},
"extends": [
"prettier"
],

9
scripts/postinstall.js Normal file
View File

@ -0,0 +1,9 @@
// There doesn't appear to be a way to skip `postinstall`,
// as doing `yarn --ignore-scripts` could prevent native packages from building:
// https://github.com/yarnpkg/yarn/issues/4100
const { execSync } = require("child_process");
if (process.env.SKIP_YARN_POSTINSTALL !== "true") {
execSync("yarnpkg build", { stdio: "inherit" });
}

View File

@ -12,5 +12,6 @@
"resolveJsonModule": true,
"isolatedModules": true,
"outDir": "dist"
}
},
"include": ["src/**/*"]
}