fix(start): change the way the app is launched

* And updated README accordingly
This commit is contained in:
Florent Chehab 2020-04-20 11:03:07 +02:00
parent 033d01e1cf
commit 0ef46fea2f
No known key found for this signature in database
GPG Key ID: 9A0CE018889EA246
4 changed files with 17 additions and 13 deletions

View File

@ -35,4 +35,4 @@ COPY scripts ./scripts
COPY --from=base /opt/app/dist ./dist COPY --from=base /opt/app/dist ./dist
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT [ "npm", "run", "start:prod-no-build" ] ENTRYPOINT ["node", "scripts/server.js", "--mode=production"]

View File

@ -1,7 +1,7 @@
# whiteboard # whiteboard
This is a lightweight NodeJS collaborative Whiteboard/Sketchboard witch can easily be customized... This is a lightweight NodeJS collaborative Whiteboard/Sketchboard witch can easily be customized...
![start](https://raw.githubusercontent.com/cracker0dks/whiteboard/master/doc/start.png) ![start](./doc/start.png)
## Demowhiteboard ## ## Demowhiteboard ##
[HERE](https://cloud13.de/testwhiteboard/) (Reset every night) [HERE](https://cloud13.de/testwhiteboard/) (Reset every night)
@ -34,14 +34,14 @@ You can run this app with and without docker
## Development ## Development
After you have installed the app, run `npm run start:dev` to lunch the backend and a frontend development server. The website will be accessible on http://locahost:8080. After you have installed the app, run `npm run start:dev` to start the backend and a frontend development server. The website will be accessible on http://locahost:8080.
## Default keyboard shortcuts ## Default keyboard shortcuts
Use keyboard shortcuts to become more productive while using Whiteboard. Use keyboard shortcuts to become more productive while using Whiteboard.
They are especially useful if you work with interactive displays such as XP-Pen Artist, Huion Kamvas and Wacom Cintiq. These devices have quick buttons (6-8 buttons and scrolling). By default, the buttons on these displays are mapped to standard Photoshop keyboard shortcuts. Keys can be configured to function effectively in other software. They are especially useful if you work with interactive displays such as XP-Pen Artist, Huion Kamvas and Wacom Cintiq. These devices have quick buttons (6-8 buttons and scrolling). By default, the buttons on these displays are mapped to standard Photoshop keyboard shortcuts. Keys can be configured to function effectively in other software.
The following are predefined shortcuts that you can override in the file [/public/js/keybinds.js](https://github.com/cracker0dks/whiteboard/blob/master/public/js/keybinds.js) The following are predefined shortcuts that you can override in the file [./src/js/keybinds.js](./src/js/keybinds.js)
Result | Windows and Linux | macOS Result | Windows and Linux | macOS
------ | -------------------- | ------- ------ | -------------------- | -------
@ -95,9 +95,9 @@ Call your site with GET parameters to change the WhiteboardID or the Username
## Security - AccessToken (Optional) ## Security - AccessToken (Optional)
To prevent clients who might know or guess the base URL from abusing the server to upload files and stuff..., you can set an accesstoken at server start. To prevent clients who might know or guess the base URL from abusing the server to upload files and stuff..., you can set an accesstoken at server start.
<b>Server (Without docker):</b> `node server.js --accesstoken="mySecToken"` <b>Server (Without docker):</b> `node scripts/server.js --accesstoken="mySecToken"`
<b>Server (With docker):</b> `docker run -d -e accesstoken="mySecToken" -p 8080:8080 rofl256/whiteboard` <b>Server (With docker):</b> `docker run -d -p 8080:8080 rofl256/whiteboard --accesstoken="mySecToken"`
Then set the same token on the client side as well: Then set the same token on the client side as well:
@ -110,9 +110,9 @@ This function allows your users to save the whiteboard directly to a webdav serv
To enable it: To enable it:
<b>Server (Without docker):</b> `node server.js --webdav=true` <b>Server (Without docker):</b> `node scripts/server.js --webdav=true`
<b>Server (With docker):</b> `docker run -d -e webdav=true -p 8080:8080 rofl256/whiteboard` <b>Server (With docker):</b> `docker run -d -p 8080:8080 rofl256/whiteboard --webdav=true`
Then set the same parameter on the client side as well: Then set the same parameter on the client side as well:
@ -127,7 +127,7 @@ Done!
## Things you may want to know ## Things you may want to know
* Whiteboards are gone if you restart the Server, so keep that in mind (or save your whiteboard) * Whiteboards are gone if you restart the Server, so keep that in mind (or save your whiteboard)
* You shoud be able to customize the layout without ever toutching the whiteboard.js (take a look at index.html & main.js) * You should be able to customize the layout without ever touching the whiteboard.js (take a look at index.html & main.js)
## All server start parameters (also docker) ## All server start parameters (also docker)
* accesstoken => take a look at "Security - AccessToken" for a full explanation * accesstoken => take a look at "Security - AccessToken" for a full explanation

View File

@ -7,8 +7,7 @@
"scripts": { "scripts": {
"build": "webpack --config config/webpack.build.js", "build": "webpack --config config/webpack.build.js",
"start:dev": "node scripts/server.js --mode=development", "start:dev": "node scripts/server.js --mode=development",
"start:prod": "npm run build && npm run start:prod-no-build", "start:prod": "npm run build && node scripts/server.js --mode=production",
"start:prod-no-build": "node scripts/server.js --mode=production",
"test": "echo \"No tests needed!\" && exit 1" "test": "echo \"No tests needed!\" && exit 1"
}, },
"repository": { "repository": {

View File

@ -9,8 +9,13 @@ const SERVER_MODES = {
const args = getArgs(); const args = getArgs();
if ( typeof args.mode === "undefined" || (args.mode !== "production" && args.mode !== "development")) { if ( typeof args.mode === "undefined") {
throw new Error("--mode=development or --mode=production is expected") // default to production mode
args.mode = "production";
}
if (args.mode !== "production" && args.mode !== "development") {
throw new Error("--mode can only be 'development' or 'production'")
} }
const server_mode = args.mode === "production" ? SERVER_MODES.PRODUCTION : SERVER_MODES.DEVELOPMENT; const server_mode = args.mode === "production" ? SERVER_MODES.PRODUCTION : SERVER_MODES.DEVELOPMENT;