Skip to content

Commit 243e728

Browse files
committed
Docker updates:
- 2 stage build process - changes needed after the PG-2.17 update and the changes to how codemirror is included. - update build instructions and other things in README.md
1 parent 775e68a commit 243e728

7 files changed

+161
-22
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
.git
21
.gitignore
32
**/.DS_Store

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.DS_Store
22
render_app.conf
3+
docker-compose.yml
34
lib/WeBWorK/htdocs/tmp/renderer/gif/*
45
lib/WeBWorK/htdocs/tmp/renderer/images/*
56
lib/WeBWorK/htdocs/DATA/*.json

Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ RUN apt-get update \
4343
libmath-random-secure-perl \
4444
libdata-structure-util-perl \
4545
liblocale-maketext-lexicon-perl \
46+
libyaml-libyaml-perl \
47+
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
48+
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
4649
&& apt-get clean \
4750
&& rm -fr /var/lib/apt/lists/* /tmp/*
4851

@@ -51,7 +54,7 @@ RUN cpanm install Mojo::Base Statistics::R::IO::Rserve Date::Format Future::Asyn
5154

5255
COPY . .
5356

54-
RUN cd lib/WeBWorK/htdocs && npm install && cd ../../..
57+
RUN cd lib/PG/htdocs && npm install && cd ../../.. && npm install
5558

5659
EXPOSE 3000
5760

DockerfileStage1

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM ubuntu:20.04
2+
MAINTAINER drdrew42
3+
4+
WORKDIR /usr/app
5+
ARG DEBIAN_FRONTEND=noninteractive
6+
ENV TZ=America/New_York
7+
8+
RUN apt-get update \
9+
&& apt-get install -y --no-install-recommends --no-install-suggests \
10+
apt-utils \
11+
git \
12+
gcc \
13+
npm \
14+
make \
15+
curl \
16+
nodejs \
17+
dvipng \
18+
openssl \
19+
libc-dev \
20+
cpanminus \
21+
libssl-dev \
22+
libgd-perl \
23+
zlib1g-dev \
24+
imagemagick \
25+
libdbi-perl \
26+
libjson-perl \
27+
libcgi-pm-perl \
28+
libjson-xs-perl \
29+
ca-certificates \
30+
libstorable-perl \
31+
libdatetime-perl \
32+
libuuid-tiny-perl \
33+
libtie-ixhash-perl \
34+
libhttp-async-perl \
35+
libnet-ssleay-perl \
36+
libarchive-zip-perl \
37+
libcrypt-ssleay-perl \
38+
libclass-accessor-perl \
39+
libstring-shellquote-perl \
40+
libextutils-cbuilder-perl \
41+
libproc-processtable-perl \
42+
libmath-random-secure-perl \
43+
libdata-structure-util-perl \
44+
liblocale-maketext-lexicon-perl \
45+
libyaml-libyaml-perl \
46+
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
47+
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
48+
&& apt-get clean \
49+
&& rm -fr /var/lib/apt/lists/* /tmp/*
50+
51+
RUN cpanm install Mojo::Base Statistics::R::IO::Rserve Date::Format Future::AsyncAwait Crypt::JWT IO::Socket::SSL CGI::Cookie \
52+
&& rm -fr ./cpanm /root/.cpanm /tmp/*
53+

DockerfileStage2

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM renderer-base:latest
2+
LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer
3+
MAINTAINER drdrew42
4+
5+
WORKDIR /usr/app
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
ENV TZ=America/New_York
8+
9+
10+
COPY . .
11+
12+
RUN cd lib/PG/htdocs && npm install && cd ../../.. && npm install
13+
14+
EXPOSE 3000
15+
16+
HEALTHCHECK CMD curl -I localhost:3000/health
17+
18+
CMD hypnotoad -f ./script/render_app

README.md

+36-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# WeBWorK Standalone Problem Renderer & Editor
22

3-
![Commit Activity](https://img.shields.io/github/commit-activity/m/drdrew42/renderer?style=plastic)
4-
![License](https://img.shields.io/github/license/drdrew42/renderer?style=plastic)
3+
![Commit Activity](https://img.shields.io/github/commit-activity/m/openwebwork/renderer?style=plastic)
4+
![License](https://img.shields.io/github/license/openwebwork/renderer?style=plastic)
55

66

77
This is a PG Renderer derived from the WeBWorK2 codebase
@@ -13,42 +13,58 @@ This is a PG Renderer derived from the WeBWorK2 codebase
1313
mkdir volumes
1414
mkdir container
1515
git clone https://github.com/openwebwork/webwork-open-problem-library volumes/webwork-open-problem-library
16-
git clone --recursive https://github.com/drdrew42/renderer container/
17-
docker build --tag renderer:1.0 ./container
18-
19-
docker run -d \
20-
--rm \
21-
--name standalone-renderer \
22-
--publish 3000:3000 \
23-
--mount type=bind,source="$(pwd)"/volumes/webwork-open-problem-library/,target=/usr/app/webwork-open-problem-library \
24-
--env MOJO_MODE=development \
25-
renderer:1.0
26-
```
16+
git clone --recursive https://github.com/openwebwork/renderer container/
2717
28-
If you have non-OPL content, it can be mounted as a volume at `/usr/app/private` by adding the following line to the `docker run` command:
18+
cd container
19+
docker build --no-cache --tag renderer-base:latest -f DockerfileStage1 .
20+
21+
# If you have a local version of docker-compose.yml you should update it
22+
# as necessary before running the next line. If not, copy the
23+
# docker-compose.yml.dist to docker-compose.yml and edit as necessary.
24+
25+
docker-compose build --no-cache
26+
27+
# You now set the MOJO_MODE and mount locations in docker-compose.yml
28+
# instead of in the docker run command
29+
30+
docker-compose up -d
2931
30-
```
31-
--mount type=bind,source=/pathToYourLocalContentRoot,target=/usr/app/private \
3232
```
3333

34-
A default configuration file is included in the container, but it can be overridden by mounting a replacement at the application root. This is necessary if, for example, you want to run the container in `production` mode.
34+
To stop the container run:
35+
```
36+
docker-compose down
37+
```
3538

39+
If you need to rebuild the container, but do not need to change the
40+
packages/installs in the stage 1 build, it suffices to:
3641
```
37-
--mount type=bind,source=/pathToYour/render_app.conf,target=/usr/app/render_app.conf \
42+
cd container
43+
docker-compose build --no-cache
3844
```
3945

46+
If you have non-OPL content, it can be mounted as a volume at `/usr/app/private` by
47+
setting the relevant mount moint in `docker-compose.yml` so that it gets mounted under
48+
`/usr/app/private`.
49+
50+
A default `render_app.conf` configuration file is included in the container,
51+
but it can be overridden by mounting a replacement at the application root
52+
using `docker-compose.yml`. This is necessary if, for example, you want to run
53+
the container in `production` mode.
54+
4055
## LOCAL INSTALL ###
4156

4257
If using a local install instead of docker:
4358

44-
* Clone the renderer and its submodules: `git clone --recursive https://github.com/drdrew42/renderer`
59+
* Clone the renderer and its submodules: `git clone --recursive https://github.com/openwebwork/renderer`
4560
* Enter the project directory: `cd renderer`
4661
* Install perl dependencies listed in Dockerfile (CPANMinus recommended)
4762
* clone webwork-open-problem-library into the provided stub ./webwork-open-problem-library
4863
- `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library`
4964
* copy `render_app.conf.dist` to `render_app.conf` and make any desired modifications
5065
* install other dependencies
51-
- `cd lib/WeBWorK/htdocs`
66+
- `npm install`
67+
- `cd lib/PG/htdocs`
5268
- `npm install`
5369
* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing root url
5470
* access on `localhost:3000` by default or otherwise specified root url

docker-compose.yml.dist

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: '3.5'
2+
3+
services:
4+
renderer:
5+
image: renderer:latest
6+
container_name: standalone-renderer
7+
8+
build:
9+
# For use/building when docker-compose.yml is in the container directory
10+
context: .
11+
# For use/building when docker-compose.yml is OUTSIDE the container directory.
12+
#context: /Path_To/container/
13+
14+
# If you would like a 1 stage build process comment out the next line, and just run "docker-compose build".
15+
dockerfile: DockerfileStage2
16+
17+
# For the 2 stage build process:
18+
# Stage 1 - base image with OS + CPAN packages
19+
# docker build --no-cache --tag renderer-base:latest -f container/DockerfileStage1 .
20+
# You can add something like
21+
# --build-arg ADDITIONAL_BASE_IMAGE_PACKAGES="vim-tiny"
22+
# to add additional packages to the base image
23+
# Stage 2 - add the renderer to the base image
24+
# docker-compose build --no-cache
25+
26+
volumes:
27+
28+
# Local render_app.conf if needed:
29+
#- "./render_app.conf:/usr/app/render_app.conf"
30+
31+
# OPL - from standard location
32+
- "../volumes/webwork-open-problem-library:/usr/app/webwork-open-problem-library"
33+
34+
# Private problem directories - from standard location
35+
#- "./volumes/private:/usr/app/private"
36+
37+
#hostname: myhost.mydomain.edu
38+
39+
ports:
40+
- "3000:3000"
41+
42+
environment:
43+
MOJO_MODE: development
44+
45+
# The system timezone for the container can be set using
46+
#SYSTEM_TIMEZONE: zone/city
47+
# where zone/city must be a valid setting.
48+
# "/usr/bin/timedatectl list-timezones" on an Ubuntu system with
49+
# that tool installed will find valid values.

0 commit comments

Comments
 (0)