You can quickly start with pre-built docker image.
docker pull ghcr.io/nownabe/mclauncher:latest
You can run mclauncher on Cloud Run by clicking this button.
- You should add
roles/compute.instanceAdmin.v1
for your Minecraft server instance to the service account used for the Cloud Run service. If you want to minimize permissions, you can create your own custom role. - Firestore and Firebase Authentication must be initialized. For now, mclauncher supports only Google provider for Firebase Authentication.
Environment variables:
PORT
(required)INSTANCE_ZONE
(required)INSTANCE_NAME
(required)SHUTTER_AUTHORIZED_EMAIL
(required) - email of service account which calls/shutter
.FIREBASE_CREDENTIALS_JSON
(required) - used for Firebase Authentication and Firestore.FIREBASE_CONFIG_JSON
(required)TITLE
(optional) - default ismclauncher
.WEB_CONCURRENCY
(optional) - default is4
.SHUTTER_COUNT_TO_SHUTDOWN
(optional) - If the count of consecutive vacant of the server counted by/shutter
exceeds this count,/shutter
shuts down the instance.
Install dependencies with poetry.
poetry install
Run Firestore emulator.
firebase emulators:start
Set environment variables.
export FIREBASE_CONFIG_JSON='{"apiKey":"...", ...}'
export FIREBASE_CREDENTIALS_JSON="$(cat firebase.credentials.json)"
export FIRESTORE_EMULATOR_HOST="localhost:8080"
export GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/gcpproject.credentials.json"
export INSTANCE_ZONE="asia-northeast1-a"
export INSTANCE_NAME="minecraft-instance"
export SHUTTER_AUTHORIZED_EMAIL="mclauncher@example.com"
If you haven't added your email as an authorized user, run tools/add_authorized_users.py
.
poetry run python tools/add_authorized_users.py you@example.com
Run the development server.
poetry run uvicorn main:app --reload
Or you can run and debug with Ctrl + Shift + D
.
You can forward ports. See the detail: Forwarding ports in your codespace - GitHub Docs.
Test.
poetry run pytest