-
-
Notifications
You must be signed in to change notification settings - Fork 32
Docker
This page describes both running and developing virtualtabletop in a Docker container.
This section explains how to run virtualtabletop in a Docker container. Hopefully we can get this into the Docker Hub but for now this is how you get it up and running:
Save this as Dockerfile
in an empty directory (I use /path/to/vtt
as an example):
FROM node:18-alpine
RUN apk add curl unzip \
&& curl -LO https://github.com/ArnoldSmith86/virtualtabletop/archive/refs/heads/main.zip \
&& unzip main.zip \
&& rm main.zip \
&& apk del curl unzip \
&& cd virtualtabletop-main \
&& npm install --prod
EXPOSE 8272
VOLUME /virtualtabletop-main/save
WORKDIR /virtualtabletop-main
CMD ["npm", "start"]
Now run docker build
to create an image (named virtualtabletop
in this example):
sudo docker build -t virtualtabletop /path/to/vtt
Afterwards you can run it in a new container (also named virtualtabletop
) like this:
sudo docker run --name virtualtabletop -v vtt:/virtualtabletop-main/save -p 0.0.0.0:80:8272 -e "NODE_ENV=production" virtualtabletop
-
--name
names the resulting container. This can be anything you want. -
-e
sets an environment variable. -
-v
creates a persistent volume in/var/lib/docker/volumes/vtt
to store save data. -
-p
makes the internal port8272
available from the outside of the machine as port80
.
This is an example setup to isolate node environment just for developing virtualtabletop.
First, prepare directories, repo, and config.json
:
#!/usr/bin/env bash
mkdir -p virtualtabletop
cd virtualtabletop
# put git repo in a directory called code
git clone https://github.com/ArnoldSmith86/virtualtabletop.git code
# create config.json, and edit it as needed. This will be mounted later.
cp code/config.template.json config.json
# home directory for docker-compose to mount as node home
# so we can keep global node tools persistent (see docker-compose.yaml)
mkdir -p nodehome/app
Then create virtualtabletop/docker-compose.yaml
:
version: "3.7"
services:
virtualtabletop:
image: node:19.3.0-alpine3.16
user: "node"
working_dir: /home/node/app
environment:
#- NODE_ENV=production
- PORT=8272
volumes:
- ${PWD}/nodehome:/home/node
- ${PWD}/code:/home/node/app
- ${PWD}/config.json:/home/node/app/config.json
ports:
- "8272:8272"
# development
command: sh -c "npm i; NOCOMPRESS=1 npx nodemon -e js,mjs,css,html,json --ignore save/ --ignore coverage/ --ignore tests/ --inspect server.mjs"
# uncomment this if you don't want the app to automatically start
#command: tail -F /dev/null
Then you can use docker-copmose up
to bring up the container. You can edit the files directly in virtualtabletop/code
from the host system.
If you need to run specific commands in the container, access its shell by:
$ docker-compose exec virtualtabletop sh
(use exit
to leave)
To enter the root shell:
$ docker-compose exec -u root virtualtabletop sh
Note that this setup does not support testcafe
, which requires a graphic setup in the container. While there there various techniques (e.g. mount X sockets, vnc, ssh -X
, etc.), it is beyond the scope here. If you have a simple setup that can achieve this, please share with us.
If you want to put your own games files on your local server, you must set the allowPublicLibraryEdits
property in the config.json file to true. For more info, see https://github.com/ArnoldSmith86/virtualtabletop/wiki/config.json#allowpubliclibraryedits
- Widgets
- Functions, automation, and routines
- Dynamic Expressions and using variables
- Math, string, array, color, JSON functions
- Cards and Decks
- Editing JSON
- Using CSS
- Fonts
- Publicly available games
- Tutorials
- Available icons, card backs, button styles, and other images
- Demonstration Features
- Useful Code Snippets