diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index eeea401..ec705dd 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -1,35 +1,138 @@ -name: Push to Docker Hub +name: Push to Docker Hub and GHCR on: push: - branches: + branches: - master - tags: - - 'v*' + +env: + DOCKERHUB_IMAGE: cryptoxic/fvtt-docker + GHCR_IMAGE: ghcr.io/kryptoxic/fvtt-docker jobs: build: - runs-on: ubuntu-latest - + runs-on: self-hosted + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm/v6 + - linux/arm/v7 + - linux/arm64/v8 + - linux/s390x + steps: - - uses: actions/checkout@v4 + - name: Prepare platform pair + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - uses: actions/checkout@v6 - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - + uses: docker/setup-qemu-action@v4 + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v4 - name: Login to Docker Hub - uses: docker/login-action@v3 + uses: docker/login-action@v4 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push - uses: docker/build-push-action@v5 + - name: Compute version + id: vars + run: echo "version=$(date -u +%Y.%m.%d)-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v6 + with: + images: ${{ env.DOCKERHUB_IMAGE }} + tags: | + type=raw,value=${{ steps.vars.outputs.version }} + + - name: Build and push by digest + id: build + uses: docker/build-push-action@v7 with: context: . - platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x - push: true - tags: direckthit/fvtt-docker:latest + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,name=${{ env.DOCKERHUB_IMAGE }},push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v7 + with: + name: digests-${{ env.PLATFORM_PAIR }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: self-hosted + needs: + - build + permissions: + contents: read + packages: write + + steps: + - name: Download digests + uses: actions/download-artifact@v8 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Compute version + id: vars + run: echo "version=$(date -u +%Y.%m.%d)-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v6 + with: + images: | + ${{ env.DOCKERHUB_IMAGE }} + ${{ env.GHCR_IMAGE }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=${{ steps.vars.outputs.version }},enable={{is_default_branch}} + + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.DOCKERHUB_IMAGE }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.version }} diff --git a/Dockerfile b/Dockerfile index f2ba562..3843177 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine +FROM node:22-alpine RUN deluser node && \ mkdir -p /opt/foundryvtt/resources/app && \ diff --git a/README.md b/README.md index 97fb2d3..9eaf746 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,20 @@ # Foundry VTT - Docker - +[![amd64](https://img.shields.io/docker/v/cryptoxic/fvtt-docker?arch=amd64&label=amd64&style=flat-square&filter=!latest)](https://hub.docker.com/r/cryptoxic/fvtt-docker/tags) +[![arm/v6](https://img.shields.io/docker/v/cryptoxic/fvtt-docker?arch=arm&variant=v6&label=arm%2Fv6&style=flat-square&filter=!latest)](https://hub.docker.com/r/cryptoxic/fvtt-docker/tags) +[![arm/v7](https://img.shields.io/docker/v/cryptoxic/fvtt-docker?arch=arm&variant=v7&label=arm%2Fv7&style=flat-square&filter=!latest)](https://hub.docker.com/r/cryptoxic/fvtt-docker/tags) +[![arm64](https://img.shields.io/docker/v/cryptoxic/fvtt-docker?arch=arm64&variant=v8&label=arm64&style=flat-square&filter=!latest)](https://hub.docker.com/r/cryptoxic/fvtt-docker/tags) +[![s390x](https://img.shields.io/docker/v/cryptoxic/fvtt-docker?arch=s390x&label=s390x&style=flat-square&filter=!latest)](https://hub.docker.com/r/cryptoxic/fvtt-docker/tags) ## Foundry VTT - Docker -This repository hosts the Foundry VTT `Dockerfile` for [direckthit/fvtt-docker](https://hub.docker.com/r/direckthit/fvtt-docker) on Docker Hub. +This repository hosts the Foundry VTT `Dockerfile` for [cryptoxic/fvtt-docker](https://hub.docker.com/r/cryptoxic/fvtt-docker) on Docker Hub and [ghcr.io/kryptoxic/fvtt-docker](https://github.com/Kryptoxic/fvtt-docker/pkgs/container/fvtt-docker) on the GitHub Container Registry. + +> Originally created by [BenjaminPrice](https://github.com/BenjaminPrice/fvtt-docker), based on the original [direckthit/fvtt-docker](https://hub.docker.com/r/direckthit/fvtt-docker) image. This fork is maintained by [Kryptoxic](https://github.com/Kryptoxic) following the archival of the upstream repository. > [Foundry VTT](https://foundryvtt.com/) is a virtual tabletop for playing tabletop RPG games such as Dungeons & Dragons 5e. -I've also included a basic `docker-compose.yaml` file which you can use to get things up and running quickly. +A basic `docker-compose.yaml` file is included to get things up and running quickly. ### **Note** At the request of the author of Foundry VTT, the source code for Foundry VTT is not included in this image. @@ -19,30 +25,21 @@ You will need to manually download the zip file from your Foundry VTT account on ## **Recommended Hosting** -I recommend you host your server on a dedicated server. They can be quite cheap. +Hosting your server on a dedicated server is recommended. These can be quite cheap. If you don't have a preferred provider, a $5 Ubuntu server from either of the below options are good considerations. ### **Hosting Options** -#### Linode +#### Linode (Akamai) A great cheap provider with servers all around the globe. They're one of the older VPS providers still around. -**This is where I personally choose to host my games** - -[Sign Up](https://www.linode.com/?r=311b3d1469c9a251020a9385437b21266fa076f0) - -A couple promo codes you can try during registration (no guarantees): - -- `OBJECT20` - $20 Credit -- `LINODE10` - $10 Credit +[Sign Up](https://www.linode.com/) #### Digital Ocean Another great cheap provider with servers all around the globe. -[Sign Up](https://m.do.co/c/879607663421) - -Using the above link should grant you a $100 credit (expires in 60 days). +[Sign Up](https://www.digitalocean.com/) --- @@ -64,13 +61,13 @@ Using the above link should grant you a $100 credit (expires in 60 days). Manually download it or use the command below ```shell -wget https://raw.githubusercontent.com/BenjaminPrice/fvtt-docker/master/docker-compose.yaml +wget https://raw.githubusercontent.com/Kryptoxic/fvtt-docker/master/docker-compose.yaml ``` ### Step 2 - Download the Foundry VTT Zip File - Navigate to your User Profile page and find your Software Download Links on your license page. -- Download the `Linux` version. +- Download the `Node.js` version. - Save it to the same directory as the `docker-compose.yaml` file from the previous step. ### Step 3 - Create your data directory @@ -151,3 +148,33 @@ Replace `127.0.0.1` with your own IP address. you can customize your login screen using a fix such as this one: [prettier login screen](https://github.com/TheEpicSnowWolf/Foundry-VTT-Prettier-Login-Screen) +--- + +## **Pinning to a Specific Version** + +The provided `docker-compose.yaml` uses the `:latest` tag, which always tracks the most recent build of `master`. For a more stable deployment, pin to a tagged release by updating the `image:` line in your `docker-compose.yaml`: + +```yaml +image: cryptoxic/fvtt-docker:1.0.0 +``` + +Available versions are listed on the [Docker Hub tags page](https://hub.docker.com/r/cryptoxic/fvtt-docker/tags) and the [GHCR package page](https://github.com/Kryptoxic/fvtt-docker/pkgs/container/fvtt-docker). + +## **Using GitHub Container Registry Instead** + +The same multi-architecture image is published to both Docker Hub and the GitHub Container Registry. To pull from GHCR instead, replace the `image:` line in `docker-compose.yaml` with: + +```yaml +image: ghcr.io/kryptoxic/fvtt-docker:latest +``` + +## **Supported Architectures** + +Each tagged image is built for the following platforms: + +- `linux/amd64` +- `linux/arm/v6` +- `linux/arm/v7` +- `linux/arm64/v8` +- `linux/s390x` + diff --git a/docker-compose.yaml b/docker-compose.yaml index b8a2b01..eea566a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,6 @@ -version: '3' services: foundryvtt: - image: direckthit/fvtt-docker:latest + image: cryptoxic/fvtt-docker:latest container_name: fvtt ports: - 30000:30000 diff --git a/run-server.sh b/run-server.sh index 2f70e0d..7e46f8a 100644 --- a/run-server.sh +++ b/run-server.sh @@ -1,18 +1,20 @@ #!/bin/sh -# look for a file name foundryvtt-.....zip or FoundryVTT...zip, copy it to -# /opt/foundryvtt, unzip and remove it. Then start the foundry app +set -e # Exit immediately on error cd /opt/foundryvtt || exit echo "Copying zip file..." -find /host -type f -name '[f,F]oundry[vtt,VTT]*.zip' -exec cp '{}' . ';' +find /host -type f -name '[Ff]oundry*.zip' -exec cp '{}' . ';' echo "Unzipping..." unzip -o ./*.zip -d unpacked && rm ./*.zip -echo "Moving to mapped directory" +echo "Cleaning target app folder..." +rm -rf resources/app/* + +echo "Moving to mapped directory..." mv unpacked/* resources/app/ -echo "Starting node" +echo "Starting node..." cd resources/app -node main.mjs --dataPath=/data/foundryvtt \ No newline at end of file +exec node main.mjs --dataPath=/data/foundryvtt \ No newline at end of file