(core) add Dockerfile for grist-core

Summary:
This adds a two-stage Dockerfile for grist-core. The first stage builds
Grist, and the second collects all files needed to run Grist.

The resulting image is about 600 MB which is quite a bit bigger
than it needs to be, but seems fine for now when the first goal is
to establish that people can open and edit Grist files on their
own infrastructure.

The image uses stock python rather than our sandboxed python for now.

Test Plan: manual

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2637
pull/6/head
Paul Fitzpatrick 4 years ago
parent a4929bde72
commit 4d3777578e

@ -0,0 +1,11 @@
# explicitly list the files needed by docker.
*
!package.json
!tsconfig.json
!stubs
!app
!buildtools
!ormconfig.js
!static
!bower_components
!sandbox

3
.gitignore vendored

@ -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

@ -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 <image>
# 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

@ -0,0 +1 @@
../node_modules/bootstrap

@ -0,0 +1 @@
../node_modules/bootstrap-datepicker

@ -0,0 +1 @@
../node_modules/jquery

@ -0,0 +1 @@
../node_modules/components-jqueryui

@ -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": "",

Loading…
Cancel
Save