Skip to content

Commit

Permalink
(core) add Dockerfile for grist-core
Browse files Browse the repository at this point in the history
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
  • Loading branch information
paulfitz committed Oct 12, 2020
1 parent a4929bd commit 4d37775
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions bower_components/bootstrap
1 change: 1 addition & 0 deletions bower_components/bootstrap-datepicker
1 change: 1 addition & 0 deletions bower_components/jquery
1 change: 1 addition & 0 deletions bower_components/jqueryui
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down

0 comments on commit 4d37775

Please sign in to comment.