├── .gitattributes ├── Dockerfile ├── docker-compose.yml ├── .github └── workflows │ └── ci_cd.yml ├── init.sh └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM httpd 2 | ENV PUID=${PUID:-1000} 3 | ENV PGID=${PGID:-1000} 4 | COPY init.sh /init.sh 5 | RUN apt-get update && \ 6 | apt-get -y upgrade && \ 7 | apt-get -y install curl git jq && \ 8 | chmod +x /init.sh 9 | 10 | RUN echo "\n"\ 11 | " SetHandler server-status\n"\ 12 | " Order deny,allow\n"\ 13 | " Allow from all\n"\ 14 | "\n"\ 15 | >> /usr/local/apache2/conf/httpd.conf 16 | 17 | WORKDIR /usr/local/apache2/htdocs/ 18 | RUN chown -R $PUID:$PGID /usr/local/apache2/htdocs 19 | CMD ["/bin/bash","/init.sh"] -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | 5etools-docker: 4 | container_name: 5etools-docker 5 | image: jafner/5etools-docker 6 | volumes: 7 | - ~/5etools-docker/htdocs:/usr/local/apache2/htdocs 8 | ports: 9 | - 8080:80/tcp 10 | environment: 11 | - IMG=FALSE # Set to TRUE to pull images from https://github.com/5etools-mirror-2/5etools-img (as a Git submodule) 12 | #- OFFLINE_MODE=TRUE # Optional. Expects "TRUE" or "FALSE". Disables checking for new updates. 13 | 14 | # Uncomment this block to use a docker-managed volume: 15 | #volumes: 16 | # 5etools-docker: -------------------------------------------------------------------------------- /.github/workflows/ci_cd.yml: -------------------------------------------------------------------------------- 1 | name: CI/CD 2 | 3 | on: 4 | # Triggers the workflow when changes are made to the image on the main branch 5 | push: 6 | branches: [ main ] 7 | paths-ignore: # don't run this workflow if no changes have been made to the docker image 8 | - '.github/**' 9 | - 'docker-compose.yml' 10 | - 'README.md' 11 | pull_request: 12 | branches: [ main ] 13 | paths-ignore: # don't run this workflow if no changes have been made to the docker image 14 | - '.github/**' 15 | - 'docker-compose.yml' 16 | - 'README.md' 17 | # Allows you to run this workflow manually from the Actions tab 18 | workflow_dispatch: 19 | 20 | jobs: 21 | ci: 22 | name: Build and push Docker image to Docker Hub 23 | runs-on: ubuntu-latest 24 | steps: 25 | - name: Check out the repo 26 | uses: actions/checkout@v2 27 | 28 | - name: Log into Docker Hub 29 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 30 | with: 31 | username: ${{ secrets.DOCKERHUB_USERNAME }} 32 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 33 | 34 | - name: Extract metadata (tags, labels) for Docker 35 | id: meta 36 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 37 | with: 38 | images: jafner/5etools-docker 39 | tags: | 40 | latest 41 | type=edge 42 | type=sha 43 | 44 | - name: Set up QEMU 45 | uses: docker/setup-qemu-action@master 46 | with: 47 | platforms: all 48 | 49 | - name: Set up Docker Buildx 50 | id: buildx 51 | uses: docker/setup-buildx-action@master 52 | 53 | - name: Build and push the Docker image 54 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 55 | with: 56 | context: . 57 | builder: ${{ steps.buildx.outputs.name }} 58 | platforms: linux/amd64,linux/arm64,linux/arm/v7 59 | push: true 60 | tags: ${{ steps.meta.outputs.tags }} 61 | labels: ${{ steps.meta.outputs.labels }} 62 | 63 | - name: Docker Hub Description 64 | uses: peter-evans/dockerhub-description@v2 65 | with: 66 | username: ${{ secrets.DOCKERHUB_USERNAME }} 67 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 68 | repository: jafner/5etools-docker 69 | -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Print current user ID 4 | id 5 | 6 | # Ensure clean, non-root ownership of the htdocs directory. 7 | chown -R $PUID:$PGID /usr/local/apache2/htdocs 8 | 9 | # Delete index.html if it's the stock apache file. Otherwise it impedes the git clone. 10 | if grep -Fq '

It works!

' "/usr/local/apache2/htdocs/index.html"; then 11 | rm /usr/local/apache2/htdocs/index.html 12 | fi 13 | 14 | # If the user doesn't want to update from a source, 15 | # check for local version. 16 | # If local version is found, print version and start server. 17 | # If no local version is found, print error message and exit. 18 | if [ "$OFFLINE_MODE" = "TRUE" ]; then 19 | echo " === Offline mode is enabled. Will try to launch from local files. Checking for local version..." 20 | if [ -f /usr/local/apache2/htdocs/package.json ]; then 21 | VERSION=$(jq -r .version package.json) # Get version from package.json 22 | echo " === Starting version $VERSION" 23 | httpd-foreground 24 | else 25 | echo " === No local version detected. Exiting." 26 | exit 1 27 | fi 28 | fi 29 | 30 | # Move to the working directory for working with files. 31 | cd /usr/local/apache2/htdocs 32 | 33 | echo " === Checking directory permissions for /usr/local/apache2/htdocs" 34 | ls -ld /usr/local/apache2/htdocs 35 | 36 | DL_LINK=${DL_LINK:-https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git} 37 | IMG_LINK=${IMG_LINK:-https://github.com/5etools-mirror-2/5etools-img} 38 | 39 | echo " === Using GitHub mirror at $DL_LINK" 40 | if [ ! -d "./.git" ]; then # if no git repository already exists 41 | echo " === No existing git repository, creating one" 42 | git config --global user.email "autodeploy@localhost" 43 | git config --global user.name "AutoDeploy" 44 | git config --global pull.rebase false # Squelch nag message 45 | git config --global --add safe.directory '/usr/local/apache2/htdocs' # Disable directory ownership checking, required for mounted volumes 46 | git clone $DL_LINK . # clone the repo with no files and no object history 47 | else 48 | echo " === Using existing git repository" 49 | git config --global --add safe.directory '/usr/local/apache2/htdocs' # Disable directory ownership checking, required for mounted volumes 50 | fi 51 | 52 | if [[ "$IMG" == "TRUE" ]]; then # if user wants images 53 | echo " === Pulling images from GitHub... (This will take a while)" 54 | git submodule add -f $IMG_LINK /usr/local/apache2/htdocs/img 55 | fi 56 | 57 | echo " === Pulling latest files from GitHub..." 58 | git checkout 59 | git fetch 60 | git pull --depth=1 61 | VERSION=$(jq -r .version package.json) # Get version from package.json 62 | 63 | if [[ `git status --porcelain` ]]; then 64 | git restore . 65 | fi 66 | 67 | echo " === Starting version $VERSION" 68 | 69 | httpd-foreground -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a simple image for hosting your own 5eTools instance. It is based on the Apache `httpd` image and uses components of the auto-updater script from the [5eTools wiki](https://wiki.tercept.net/en/5eTools/InstallGuide). This image is built from [this GitHub repository](https://github.com/Jafner/5etools-docker). 2 | 3 | # Usage 4 | Below we talk about how to install and configure the container. 5 | 6 | ## Default Configuration 7 | You can quick-start this image by running: 8 | 9 | ``` 10 | mkdir -p ~/5etools-docker/htdocs && cd ~/5etools-docker 11 | curl -o docker-compose.yml https://raw.githubusercontent.com/Jafner/5etools-docker/main/docker-compose.yml 12 | docker-compose up -d && docker logs -f 5etools-docker 13 | ``` 14 | 15 | Then give the container a few minutes to come online (it takes a while to pull the Github repository) and it will be accessible at `localhost:8080`. 16 | When you stop the container, it will automatically delete itself. The downloaded files will remain in the `~/5etools-docker/htdocs` directory, so you can always start the container back up by running `docker-compose up -d`. 17 | 18 | ## Volume Mapping 19 | By default, I assume you want to keep downloaded files, even if the container dies. And you want the downloaded files to be located at `~/5etools-docker/htdocs`. 20 | 21 | If you want the files to be located somewhere else on your system, change the left side of the volume mapping. For example, if I wanted to keep my files at `~/data/docker/5etools`, the volume mapping would be: 22 | 23 | ``` 24 | volumes: 25 | - ~/data/docker/5etools:/usr/local/apache2/htdocs 26 | ``` 27 | 28 | Alternatively, you can have Docker or Compose manage your volume. (This makes adding homebrew practically impossible.) 29 | 30 | Use a Compose-managed volume with: 31 | ``` 32 | ... 33 | volumes: 34 | - 5etools-docker:/usr/local/apache2/htdocs 35 | ... 36 | volumes: 37 | 5etools-docker: 38 | ``` 39 | 40 | Or have the Docker engine manage the volume (as opposed to Compose). First, create the volume with `docker volume create 5etools-docker`, then add the following to your `docker-compose.yml`: 41 | ``` 42 | ... 43 | volumes: 44 | - 5etools-docker:/usr/local/apache2/htdocs 45 | ... 46 | volumes: 47 | 5etools-docker: 48 | external: true 49 | ``` 50 | 51 | ## Environment Variables 52 | The image uses environment variables to figure out how you want it to run. 53 | By default, I assume you want to automatically download the latest files from the Github mirror. Use the environment variables in the `docker-compose.yml` file to configure things. 54 | 55 | ### IMG (defaults to FALSE) 56 | Required unless OFFLINE_MODE=TRUE. 57 | Expects one of "TRUE", "FALSE" Where: 58 | > "TRUE" pulls from https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git and adds https://github.com/5etools-mirror-2/5etools-img as a submodule for image files. 59 | > "FALSE" pulls from https://github.com/5etools-mirror-2/5etools-mirror-2.github.io.git without image files. 60 | 61 | The get.5e.tools source has been down (redirecting to 5e.tools) during development. This method is not tested. 62 | 63 | ### OFFLINE_MODE 64 | Optional. Expects "TRUE" to enable. 65 | Setting this to true tells the server to run from the local files if available, or exits if there is no local version. 66 | 67 | ### PUID and PGID 68 | During the image build process, we set the owner of the `htdocs` directory to `1000:1000` by default. If you need a different UID and GID to own the files, you can build the image from the source Dockerfile and pass the PUID and PGID variables as desired. 69 | 70 | ## Integrating a reverse proxy 71 | Supporting integration of a reverse proxy is beyond the scope of this guide. 72 | However, any instructions which work for the base `httpd` (Apache) image, should also work for this, as it is minimally different. 73 | 74 | # Auto-loading homebrew 75 | To use auto-loading homebrew, you will need to use a host directory mapping as described above. 76 | 77 | 1. Online the container and wait for the container to finish starting. You can monitor its progress with `docker logs -f 5etools-docker`. 78 | 2. Assuming you are using the mapping `~/5etools-docker/htdocs:/usr/local/apache2/htdocs` place your homebrew json files into the `~/5etools-docker/htdocs/homebrew/` folder, then add their filenames to the `~/5etools-docker/htdocs/homebrew/index.json` file. 79 | For example, if your homebrew folder contains: 80 | ``` 81 | index.json 82 | 'Jafner; JafnerBrew Campaigns.json' 83 | 'Jafner; JafnerBrew Collection.json' 84 | 'Jafner; Legendary Tomes of Knowledge.json' 85 | 'KibblesTasty; Artificer (Revised).json' 86 | ``` 87 | Then your `index.json` should look like: 88 | ```json 89 | { 90 | "readme": [ 91 | "NOTE: This feature is designed for use in user-hosted copies of the site, and not for integrating \"official\" 5etools content.", 92 | "The \"production\" version of the site (i.e., not the development ZIP) has this feature disabled. You can re-enable it by replacing `IS_DEPLOYED = \"X.Y.Z\";` in the file `js/utils.js`, with `IS_DEPLOYED = undefined;`", 93 | "This file contains as an index for other homebrew files, which should be placed in the same directory.", 94 | "For example, add \"My Homebrew.json\" to the \"toImport\" array below, and have a valid JSON homebrew file in this (\"homebrew/\") directory." 95 | ], 96 | "toImport": [ 97 | "Jafner; JafnerBrew Collection.json", 98 | "Jafner; JafnerBrew Campaigns.json", 99 | "Jafner; Legendary Tomes of Knowledge.json", 100 | "KibblesTasty; Artificer (Revised).json" 101 | ] 102 | } 103 | ``` 104 | 105 | Note the commas after each entry except the last in each array. 106 | See the [wiki page](https://wiki.5e.tools/index.php/5eTools_Install_Guide) for more information. --------------------------------------------------------------------------------