Skip to content

Docker updates #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.git
.gitignore
**/.DS_Store
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.DS_Store
render_app.conf
docker-compose.yml
lib/WeBWorK/htdocs/tmp/renderer/gif/*
lib/WeBWorK/htdocs/tmp/renderer/images/*
lib/WeBWorK/htdocs/DATA/*.json
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ RUN apt-get update \
libmath-random-secure-perl \
libdata-structure-util-perl \
liblocale-maketext-lexicon-perl \
libyaml-libyaml-perl \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* /tmp/*

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

COPY . .

RUN cd lib/WeBWorK/htdocs && npm install && cd ../../..
RUN cd lib/PG/htdocs && npm install && cd ../../.. && npm install

EXPOSE 3000

Expand Down
53 changes: 53 additions & 0 deletions DockerfileStage1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM ubuntu:20.04
MAINTAINER drdrew42

WORKDIR /usr/app
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York

RUN apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
apt-utils \
git \
gcc \
npm \
make \
curl \
nodejs \
dvipng \
openssl \
libc-dev \
cpanminus \
libssl-dev \
libgd-perl \
zlib1g-dev \
imagemagick \
libdbi-perl \
libjson-perl \
libcgi-pm-perl \
libjson-xs-perl \
ca-certificates \
libstorable-perl \
libdatetime-perl \
libuuid-tiny-perl \
libtie-ixhash-perl \
libhttp-async-perl \
libnet-ssleay-perl \
libarchive-zip-perl \
libcrypt-ssleay-perl \
libclass-accessor-perl \
libstring-shellquote-perl \
libextutils-cbuilder-perl \
libproc-processtable-perl \
libmath-random-secure-perl \
libdata-structure-util-perl \
liblocale-maketext-lexicon-perl \
libyaml-libyaml-perl \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* /tmp/*

RUN cpanm install Mojo::Base Statistics::R::IO::Rserve Date::Format Future::AsyncAwait Crypt::JWT IO::Socket::SSL CGI::Cookie \
&& rm -fr ./cpanm /root/.cpanm /tmp/*

18 changes: 18 additions & 0 deletions DockerfileStage2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM renderer-base:latest
LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer
MAINTAINER drdrew42

WORKDIR /usr/app
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York


COPY . .

RUN cd lib/PG/htdocs && npm install && cd ../../.. && npm install

EXPOSE 3000

HEALTHCHECK CMD curl -I localhost:3000/health

CMD hypnotoad -f ./script/render_app
7 changes: 4 additions & 3 deletions Dockerfile_with_OPL
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ RUN apt-get update \
libmath-random-secure-perl \
libdata-structure-util-perl \
liblocale-maketext-lexicon-perl \
libyaml-libyaml-perl \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* /tmp/*

Expand All @@ -62,9 +65,7 @@ RUN rm -r webwork-open-problem-library-master/

COPY . .

RUN cp render_app.conf.dist render_app.conf

RUN cd lib/WeBWorK/htdocs && npm install && cd ../../..
RUN cd lib/PG/htdocs && npm install && cd ../../.. && npm install

EXPOSE 3000

Expand Down
60 changes: 40 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# WeBWorK Standalone Problem Renderer & Editor

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


This is a PG Renderer derived from the WeBWorK2 codebase
Expand All @@ -13,42 +13,62 @@ This is a PG Renderer derived from the WeBWorK2 codebase
mkdir volumes
mkdir container
git clone https://github.com/openwebwork/webwork-open-problem-library volumes/webwork-open-problem-library
git clone --recursive https://github.com/drdrew42/renderer container/
docker build --tag renderer:1.0 ./container

docker run -d \
--rm \
--name standalone-renderer \
--publish 3000:3000 \
--mount type=bind,source="$(pwd)"/volumes/webwork-open-problem-library/,target=/usr/app/webwork-open-problem-library \
--env MOJO_MODE=development \
renderer:1.0
```
git clone --recursive https://github.com/openwebwork/renderer container/

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:
cd container
docker build --no-cache --tag renderer-base:latest -f DockerfileStage1 .

# If you have a local version of docker-compose.yml you should update it
# as necessary before running the next line. If not, copy the
# docker-compose.yml.dist to docker-compose.yml and edit as necessary.

docker-compose build --no-cache

# You set the MOJO_MODE and mount locations in docker-compose.yml
# unlike in the past where it was done in the docker run command

docker-compose up -d

```
--mount type=bind,source=/pathToYourLocalContentRoot,target=/usr/app/private \
```

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.
To stop the container run:
```
docker-compose down
```

If you need to rebuild the container, but do not need to change the
packages/installs in the stage 1 build, it suffices to:
```
--mount type=bind,source=/pathToYour/render_app.conf,target=/usr/app/render_app.conf \
cd container
git submodule update
docker-compose build --no-cache
```

Note: the use of `git submodule update` above is needed to make sure that the PG tree
which will be included in the Docker image is up to date.

If you have non-OPL content, it can be mounted as a volume at `/usr/app/private` by
setting the relevant mount moint in `docker-compose.yml` so that it gets mounted under
`/usr/app/private`.

A default `render_app.conf` configuration file is included in the container,
but it can be overridden by mounting a replacement at the application root
using `docker-compose.yml`. This is necessary if, for example, you want to run
the container in `production` mode.

## LOCAL INSTALL ###

If using a local install instead of docker:

* Clone the renderer and its submodules: `git clone --recursive https://github.com/drdrew42/renderer`
* Clone the renderer and its submodules: `git clone --recursive https://github.com/openwebwork/renderer`
* Enter the project directory: `cd renderer`
* Install perl dependencies listed in Dockerfile (CPANMinus recommended)
* clone webwork-open-problem-library into the provided stub ./webwork-open-problem-library
- `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library`
* copy `render_app.conf.dist` to `render_app.conf` and make any desired modifications
* install other dependencies
- `cd lib/WeBWorK/htdocs`
- `npm install`
- `cd lib/PG/htdocs`
- `npm install`
* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing root url
* access on `localhost:3000` by default or otherwise specified root url
Expand Down
49 changes: 49 additions & 0 deletions docker-compose.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3.5'

services:
renderer:
image: renderer:latest
container_name: standalone-renderer

build:
# For use/building when docker-compose.yml is in the container directory
context: .
# For use/building when docker-compose.yml is OUTSIDE the container directory.
#context: /Path_To/container/

# If you would like a 1 stage build process comment out the next line, and just run "docker-compose build".
dockerfile: DockerfileStage2

# For the 2 stage build process:
# Stage 1 - base image with OS + CPAN packages
# docker build --no-cache --tag renderer-base:latest -f container/DockerfileStage1 .
# You can add something like
# --build-arg ADDITIONAL_BASE_IMAGE_PACKAGES="vim-tiny"
# to add additional packages to the base image
# Stage 2 - add the renderer to the base image
# docker-compose build --no-cache

volumes:

# Local render_app.conf if needed:
#- "./render_app.conf:/usr/app/render_app.conf"

# OPL - from standard location
- "../volumes/webwork-open-problem-library:/usr/app/webwork-open-problem-library"

# Private problem directories - from standard location
#- "./volumes/private:/usr/app/private"

#hostname: myhost.mydomain.edu

ports:
- "3000:3000"

environment:
MOJO_MODE: development

# The system timezone for the container can be set using
#SYSTEM_TIMEZONE: zone/city
# where zone/city must be a valid setting.
# "/usr/bin/timedatectl list-timezones" on an Ubuntu system with
# that tool installed will find valid values.