diff --git a/Dockerfile b/Dockerfile index ffd40de..7e5e0cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,15 +5,23 @@ RUN apk update && apk add --no-cache \ unzip \ && rm -rf /var/cache/apk/* -RUN mkdir -p /foundry /data +RUN curl -fsSL https://github.com/filebrowser/filebrowser/releases/latest/download/linux-amd64-filebrowser.tar.gz \ + | tar -xzC /usr/local/bin filebrowser \ + && chmod +x /usr/local/bin/filebrowser -WORKDIR /foundry +RUN mkdir -p /foundry /data /config COPY ./build/foundry /foundry/ +COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh -EXPOSE 30000 +RUN chmod +x /usr/local/bin/entrypoint.sh + +ENV FILEBROWSER_USERNAME=admin + +EXPOSE 30000 8080 VOLUME [ "/data" ] VOLUME [ "/foundry" ] +VOLUME [ "/config" ] -CMD ["/foundry/main.mjs", "--port=30000", "--headless", "--noupdate", "--dataPath=/data"] \ No newline at end of file +ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 381a479..aa0944a 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,10 @@ docker-build: docker build -t foundryvtt:$(FOUNDRY_VERSION) . run: - docker run -p 30000:30000 foundryvtt:$(FOUNDRY_VERSION) + docker run -p 30000:30000 -p 8080:8080 foundryvtt:$(FOUNDRY_VERSION) + +docker-push: + docker tag foundryvtt:$(FOUNDRY_VERSION) gitgud.foo/javif89/foundryvtt-docker:$(FOUNDRY_VERSION) + docker push gitgud.foo/javif89/foundryvtt-docker:$(FOUNDRY_VERSION) build-run: docker-build run \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce8aef4 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# FoundryVTT Dockerized + +Docker image to deploy FoundryVTT instances with integrated file browser for data management. + +## Services + +- **FoundryVTT**: Game server running on port 30000 +- **FileBrowser**: Web-based file manager for `/data` directory on port 8080 + +## Ports + +- `30000`: FoundryVTT web interface +- `8080`: FileBrowser web interface + +## Volume bindings + +- `/foundry`: FoundryVTT application files +- `/data`: Game data and user files (accessible via FileBrowser) +- `/config`: FileBrowser configuration and database + +## Environment Variables + +- `FILEBROWSER_USERNAME`: FileBrowser login username (default: `admin`) +- `FILEBROWSER_PASSWORD`: FileBrowser login password (default: `password`) + +## Usage + +```bash +docker run -d \ + -p 30000:30000 \ + -p 8080:8080 \ + -v /your/foundry:/foundry \ + -v /your/data:/data \ + -v /your/config:/config \ + -e FILEBROWSER_USERNAME=myuser \ + -e FILEBROWSER_PASSWORD=mypass \ + your-image-name +``` + +Access FoundryVTT at `http://localhost:30000` and FileBrowser at `http://localhost:8080` \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..cea5e48 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +if [ -z "$FILEBROWSER_PASSWORD" ]; then + FILEBROWSER_PASSWORD=$(tr -dc 'A-Za-z0-9!@#$%^&*()_+' < /dev/urandom | head -c 16) +fi + +echo "=========================================" +echo "FILEBROWSER ADMIN CREDENTIALS" +echo "=========================================" +echo "Username: $FILEBROWSER_USERNAME" +echo "Password: $FILEBROWSER_PASSWORD" +echo "=========================================" + +filebrowser config init --database /config/filebrowser.db + +if ! filebrowser users ls --database /config/filebrowser.db | grep -q "^$FILEBROWSER_USERNAME"; then + echo "Creating admin user: $FILEBROWSER_USERNAME" + filebrowser users add $FILEBROWSER_USERNAME $FILEBROWSER_PASSWORD --database /config/filebrowser.db --perm.admin +else + echo "Admin user $FILEBROWSER_USERNAME already exists, skipping creation" +fi + +filebrowser --port 8080 --root /data --address 0.0.0.0 --database /config/filebrowser.db & +FILEBROWSER_PID=$! +exec node /foundry/main.mjs --port=30000 --headless --noupdate --dataPath=/data diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh deleted file mode 100644 index e69de29..0000000