From 4b83c47637e6e64eef64dfd20547b7490b2bf27a Mon Sep 17 00:00:00 2001 From: throwaway Date: Tue, 4 Aug 2026 23:03:19 -0700 Subject: [PATCH] read values from env and add Dockerfile --- .gitignore | 1 + docs/docker.md | 4 +++ docs/docker_4play.md | 48 +++++++++++++++++++++++++++++++++ extra/4play/Dockerfile | 19 +++++++++++++ extra/4play/docker-compose.yaml | 24 +++++++++++++++++ extra/4play/package-lock.json | 47 ++++++++++++++++++++++++++++++++ extra/4play/package.json | 20 ++++++++++++++ extra/4play/page-render.js | 6 ++--- 8 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 docs/docker_4play.md create mode 100644 extra/4play/Dockerfile create mode 100644 extra/4play/docker-compose.yaml create mode 100644 extra/4play/package-lock.json create mode 100644 extra/4play/package.json diff --git a/.gitignore b/.gitignore index 134e1b2..71e5e41 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ data/captcha/minecraft/ !banner/*default* scraper/curlie.html icons/* +node_modules/ diff --git a/docs/docker.md b/docs/docker.md index 6a94197..2b42f9f 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -150,3 +150,7 @@ services: ##### Tor You can route incoming and outgoing requests through tor by following [docker tor documentation](./docker_tor.md) + +##### 4play + +You can run the 4play sidecar by following the [docker 4play guide](./docker_4play.md) diff --git a/docs/docker_4play.md b/docs/docker_4play.md new file mode 100644 index 0000000..0675734 --- /dev/null +++ b/docs/docker_4play.md @@ -0,0 +1,48 @@ +### Running 4get and 4play via docker guide + +This setup will run both 4get and the 4play sidecar + +# Docker compose + +``` +# docker-compose.yaml + +services: + fourget: + image: luuul/4get:latest + restart: unless-stopped + environment: + - FOURGET_PROTO=http + - FOURGET_SERVER_NAME=4get.ca + - FOURGET_FPLAY_EXTERNAL_ENDPOINT=http://fourplay:3000 + - FOURGET_FPLAY_PASSWORD=cnc + - FOURGET_FPLAY_TIMEOUT=30000 + - FOURGET_FPLAY_ENABLE_API=true + ports: + - "80:80" + fourplay: + image: luuul/4get-4play:latest + environment: + - FOURPLAY_PORT=3030 + - FOURPLAY_PASSWORD=cnc + - FOURPLAY_COMMAND_TIMEOUT=5000 + ports: + - "3000:3000" + - "3030:3030" + +``` + +There is a example docker compose file available [here](../extra/4play/docker-compose.yaml) + +# Steps + +1. start the services with + +``` +docker compose up -d + +``` + +2. configure firefox + +folllow the steps in [configure](./configure.md) for firefox setup diff --git a/extra/4play/Dockerfile b/extra/4play/Dockerfile new file mode 100644 index 0000000..5ddd86f --- /dev/null +++ b/extra/4play/Dockerfile @@ -0,0 +1,19 @@ +FROM alpine:3.21 +WORKDIR /app + +RUN apk update && apk upgrade +RUN apk add nodejs npm + +COPY package*.json ./ + +RUN npm ci --only=production && npm cache clean --force + +COPY . . + +EXPOSE 3030 + +ENTRYPOINT ["node"] +CMD ["page-render.js"] + + + diff --git a/extra/4play/docker-compose.yaml b/extra/4play/docker-compose.yaml new file mode 100644 index 0000000..f11c93d --- /dev/null +++ b/extra/4play/docker-compose.yaml @@ -0,0 +1,24 @@ +# docker-compose.yaml + +services: + fourget: + image: luuul/4get:latest + restart: unless-stopped + environment: + - FOURGET_PROTO=http + - FOURGET_SERVER_NAME=4get.ca + - FOURGET_FPLAY_EXTERNAL_ENDPOINT=http://fourplay:3000 + - FOURGET_FPLAY_PASSWORD=cnc + - FOURGET_FPLAY_TIMEOUT=30000 + - FOURGET_FPLAY_ENABLE_API=true + ports: + - "80:80" + fourplay: + image: luuul/4get-4play:latest + environment: + - FOURPLAY_PORT=3030 + - FOURPLAY_PASSWORD=cnc + - FOURPLAY_COMMAND_TIMEOUT=5000 + ports: + - "3000:3000" + - "3030:3030" diff --git a/extra/4play/package-lock.json b/extra/4play/package-lock.json new file mode 100644 index 0000000..81e2539 --- /dev/null +++ b/extra/4play/package-lock.json @@ -0,0 +1,47 @@ +{ + "name": "4play", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "4play", + "version": "1.0.0", + "license": "AGPL-3.0-only", + "dependencies": { + "@lawlers/4play": "^1.2.5", + "ws": "^8.21.2" + } + }, + "node_modules/@lawlers/4play": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@lawlers/4play/-/4play-1.2.5.tgz", + "integrity": "sha512-mHxCROszXwW3XWdE+OQldJcAo3Qs9bI20VME/ZiPUvz3G2kdJaDbrMSzSwVlHmju+3dydupIE48t/ektKtewhg==", + "license": "AGPL-3.0-only", + "dependencies": { + "ws": "^8.21.1" + } + }, + "node_modules/ws": { + "version": "8.21.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.2.tgz", + "integrity": "sha512-54dMVAo4WIe6SKy3vBgN+9bJZqqQ8IMRevAkOLQALhi49qkkQDQfWdAZ8KQlXiEabw88ARXXdUrlvtbKQX+aKw==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/extra/4play/package.json b/extra/4play/package.json new file mode 100644 index 0000000..1df273f --- /dev/null +++ b/extra/4play/package.json @@ -0,0 +1,20 @@ +{ + "name": "4play", + "version": "1.0.0", + "description": "", + "repository": { + "type": "git", + "url": "https://git.lolcat.ca/lolcat/4get/" + }, + "license": "AGPL-3.0-only", + "author": "lolcat", + "type": "commonjs", + "main": "page-render.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "@lawlers/4play": "^1.2.5", + "ws": "^8.21.2" + } +} diff --git a/extra/4play/page-render.js b/extra/4play/page-render.js index af7757d..f00cd6a 100644 --- a/extra/4play/page-render.js +++ b/extra/4play/page-render.js @@ -2,9 +2,9 @@ const fplay = require("@lawlers/4play"); const http = require("http"); // 4play settings -var port = 3030; -var timeout = 30000; -var password = "cnc"; +var port = parseInt(process.env.FOURGET_FPLAY_PASSWORD) || 3030; +var timeout = parseInt(process.env.FOURGET_FPLAY_TIMEOUT) || 30000; +var password = parseInt(process.env.FOURGET_FPLAY_PASSWORD) || "cnc"; // ==================================================