diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4ea5ba3a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# explicitly list the files needed by docker. +* +!package.json +!tsconfig.json +!stubs +!app +!buildtools +!ormconfig.js +!static +!bower_components +!sandbox diff --git a/.gitignore b/.gitignore index 78a58e0e..9c243f01 100644 --- a/.gitignore +++ b/.gitignore @@ -36,9 +36,6 @@ coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt -# Bower dependency directory (https://bower.io/) -bower_components - # node-waf configuration .lock-wscript diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..828be842 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,59 @@ +################################################################################ +## Build stage +################################################################################ + +FROM node:10 as builder + +# Install all node dependencies. +ADD package.json package.json +RUN npm i + +# Build node code. +ADD tsconfig.json tsconfig.json +ADD app app +ADD stubs stubs +ADD buildtools buildtools +ADD static static +RUN npm run build:prod + +# Install all python dependencies. +ADD sandbox/requirements.txt requirements.txt +RUN \ + apt update && \ + apt install -y python-pip && \ + pip install -r requirements.txt + +################################################################################ +## Run-time stage +################################################################################ + +# Now, start preparing final image. +FROM node:10-slim + +# Copy node files. +COPY --from=builder /node_modules node_modules +COPY --from=builder /_build _build +COPY --from=builder /static static + +# Copy python files. +COPY --from=builder /usr/bin/python2.7 /usr/bin/python2.7 +COPY --from=builder /usr/lib/python2.7 /usr/lib/python2.7 +COPY --from=builder /usr/local/lib/python2.7 /usr/local/lib/python2.7 + +# Add files needed for running server. +ADD package.json package.json +ADD ormconfig.js ormconfig.js +ADD bower_components bower_components +ADD sandbox sandbox + +# Set some default environment variables to give a setup that works out of the box when +# started as: +# docker run -p 8484:8484 -it +# Variables will need to be overridden for other setups. +ENV GRIST_ORG_IN_PATH=true +ENV GRIST_HOST=0.0.0.0 +ENV APP_HOME_URL=http://localhost:8484 +ENV GRIST_DATA_DIR=docs +RUN mkdir -p docs +EXPOSE 8484 +CMD npm run start:prod diff --git a/bower_components/bootstrap b/bower_components/bootstrap new file mode 120000 index 00000000..7e74f4eb --- /dev/null +++ b/bower_components/bootstrap @@ -0,0 +1 @@ +../node_modules/bootstrap \ No newline at end of file diff --git a/bower_components/bootstrap-datepicker b/bower_components/bootstrap-datepicker new file mode 120000 index 00000000..99e1a4f6 --- /dev/null +++ b/bower_components/bootstrap-datepicker @@ -0,0 +1 @@ +../node_modules/bootstrap-datepicker \ No newline at end of file diff --git a/bower_components/jquery b/bower_components/jquery new file mode 120000 index 00000000..8b8fabc9 --- /dev/null +++ b/bower_components/jquery @@ -0,0 +1 @@ +../node_modules/jquery \ No newline at end of file diff --git a/bower_components/jqueryui b/bower_components/jqueryui new file mode 120000 index 00000000..3775ac30 --- /dev/null +++ b/bower_components/jqueryui @@ -0,0 +1 @@ +../node_modules/components-jqueryui \ No newline at end of file diff --git a/package.json b/package.json index 1a45d421..e241c54f 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "start": "tsc --build -w --preserveWatchOutput & catw app/client/*.css app/client/*/*.css -o static/bundle.css -v & webpack --config buildtools/webpack.config.js --mode development --watch --hide-modules & NODE_PATH=_build:_build/stubs nodemon -w _build/app/server -w _build/app/common _build/stubs/app/server/server.js & wait", "install:python": "buildtools/prepare_python.sh", - "build:prod": "tsc --build && webpack --config buildtools/webpack.config.js --mode production", - "start:prod": "node _build/stubs/app/server/server" + "build:prod": "tsc --build && webpack --config buildtools/webpack.config.js --mode production && cat app/client/*.css app/client/*/*.css > static/bundle.css", + "start:prod": "NODE_PATH=_build:_build/stubs node _build/stubs/app/server/server.js" }, "keywords": [], "author": "",