-
Notifications
You must be signed in to change notification settings - Fork 705
feat: infrastructure — AWS EC2 deploy, Docker stack, Grafana, Tailscale #724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,33 @@ | ||
| .vscode | ||
| node_modules | ||
| bots/*/ | ||
| !bots/* | ||
| keys.json | ||
| # Runtime bot data — large and should never be in the image | ||
| bots/*/logs/ | ||
| bots/*/histories/ | ||
| bots/*/action-code/ | ||
| bots/*/ensemble_log.json | ||
|
|
||
| # Git history | ||
| .git/ | ||
|
|
||
| # Local secrets / keys | ||
| keys.json | ||
| .env | ||
| .env.* | ||
|
|
||
| # Node dev artifacts | ||
| node_modules/ | ||
|
|
||
| # Editor / OS | ||
| .vscode/ | ||
| *.DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Tasks output | ||
| tasks/**/__pycache__/ | ||
| tasks/**/*.pyc | ||
|
|
||
| # AWS deploy scripts (not needed in container) | ||
| aws/ | ||
|
|
||
| # Docs not needed at runtime | ||
| docs/ | ||
| *.md | ||
| !README.md |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,51 +1,49 @@ | ||||||||||||||||||||||||||||||||
| # Specify a base image | ||||||||||||||||||||||||||||||||
| # FROM ubuntu:22.04 | ||||||||||||||||||||||||||||||||
| FROM node:18 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| #Install some dependencies | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| RUN apt-get -y update | ||||||||||||||||||||||||||||||||
| RUN apt-get -y install git | ||||||||||||||||||||||||||||||||
| RUN apt-get -y install unzip | ||||||||||||||||||||||||||||||||
| RUN apt-get -y install python3 | ||||||||||||||||||||||||||||||||
| RUN apt-get -y install python3-pip | ||||||||||||||||||||||||||||||||
| RUN apt-get -y install python3-boto3 | ||||||||||||||||||||||||||||||||
| RUN apt-get -y install python3-tqdm | ||||||||||||||||||||||||||||||||
| RUN apt-get -y install tmux | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| RUN git clone https://github.com/mindcraft-bots/mindcraft.git /mindcraft | ||||||||||||||||||||||||||||||||
| # Tasks.Dockerfile — Evaluation / benchmark runner | ||||||||||||||||||||||||||||||||
| # Builds a container with Mindcraft + Java 21 + AWS CLI for automated tasks. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| FROM node:22-slim AS base | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ── System dependencies (single layer) ────────────────────────────────────── | ||||||||||||||||||||||||||||||||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||||||||||||||||||||||||||||||||
| git unzip curl wget ca-certificates gnupg lsb-release \ | ||||||||||||||||||||||||||||||||
| python3 python3-pip python3-boto3 python3-tqdm tmux \ | ||||||||||||||||||||||||||||||||
| apt-transport-https \ | ||||||||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ── Adoptium Java 21 (proper GPG keyring, not deprecated apt-key) ─────────── | ||||||||||||||||||||||||||||||||
| RUN mkdir -p /etc/apt/keyrings \ | ||||||||||||||||||||||||||||||||
| && wget -qO- https://packages.adoptium.net/artifactory/api/gpg/key/public \ | ||||||||||||||||||||||||||||||||
| | gpg --dearmor -o /etc/apt/keyrings/adoptium.gpg \ | ||||||||||||||||||||||||||||||||
| && echo "deb [signed-by=/etc/apt/keyrings/adoptium.gpg] \ | ||||||||||||||||||||||||||||||||
| https://packages.adoptium.net/artifactory/deb $(lsb_release -cs) main" \ | ||||||||||||||||||||||||||||||||
| > /etc/apt/sources.list.d/adoptium.list \ | ||||||||||||||||||||||||||||||||
| && apt-get update && apt-get install -y --no-install-recommends temurin-21-jdk \ | ||||||||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ── AWS CLI v2 ────────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||
| RUN curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o /tmp/awscliv2.zip \ | ||||||||||||||||||||||||||||||||
| && unzip -q /tmp/awscliv2.zip -d /tmp \ | ||||||||||||||||||||||||||||||||
| && /tmp/aws/install \ | ||||||||||||||||||||||||||||||||
| && rm -rf /tmp/awscliv2.zip /tmp/aws | ||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+27
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ── Application code ─────────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||
| WORKDIR /mindcraft | ||||||||||||||||||||||||||||||||
| COPY ./server_data.zip /mindcraft | ||||||||||||||||||||||||||||||||
| RUN unzip server_data.zip | ||||||||||||||||||||||||||||||||
| # Copy source from the build context (this repo) rather than cloning from | ||||||||||||||||||||||||||||||||
| # GitHub at build time. A live git clone: | ||||||||||||||||||||||||||||||||
| # 1. Breaks reproducibility (upstream HEAD can change between builds) | ||||||||||||||||||||||||||||||||
| # 2. Fails in offline/air-gapped CI environments | ||||||||||||||||||||||||||||||||
| # 3. Introduces supply-chain risk (external fetch during image build) | ||||||||||||||||||||||||||||||||
| COPY . . | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| RUN npm install | ||||||||||||||||||||||||||||||||
| COPY ./server_data.zip /mindcraft/ | ||||||||||||||||||||||||||||||||
| RUN unzip -q server_data.zip && rm server_data.zip | ||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+39
|
||||||||||||||||||||||||||||||||
| COPY ./server_data.zip /mindcraft/ | |
| RUN unzip -q server_data.zip && rm server_data.zip | |
| # Optional pre-packaged server data: | |
| # If SERVER_DATA_URL is provided as a build-arg, download and extract | |
| # server_data.zip. If not provided, this step is a no-op so the image | |
| # remains buildable from a clean checkout without extra artifacts. | |
| ARG SERVER_DATA_URL | |
| RUN if [ -n "$SERVER_DATA_URL" ]; then \ | |
| echo "Downloading server_data.zip from ${SERVER_DATA_URL}..." && \ | |
| curl -fsSL "$SERVER_DATA_URL" -o server_data.zip && \ | |
| unzip -q server_data.zip && \ | |
| rm server_data.zip; \ | |
| else \ | |
| echo "SERVER_DATA_URL not set; skipping server_data.zip download."; \ | |
| fi |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm ci --omit=dev requires a lockfile (package-lock.json/npm-shrinkwrap.json). This repo doesn’t include a lockfile (and .gitignore excludes package-lock.json), so this step will fail. Either commit a lockfile and keep using npm ci, or switch back to npm install --omit=dev for this image.
| RUN npm ci --omit=dev | |
| RUN npm install --omit=dev |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| # ============================================================================= | ||||||
| # aws/backup.sh — Backup Minecraft world and bot memory to S3 | ||||||
| # ============================================================================= | ||||||
| # Run manually: bash aws/backup.sh | ||||||
| # Also runs automatically every 6 hours via cron (installed by deploy.sh) | ||||||
| # ============================================================================= | ||||||
| set -euo pipefail | ||||||
|
|
||||||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||||||
| CONFIG_FILE="${SCRIPT_DIR}/config.env" | ||||||
|
|
||||||
| GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' | ||||||
| info() { echo -e "${GREEN}[BACKUP $(date '+%Y-%m-%d %H:%M:%S')]${NC} $*"; } | ||||||
| warn() { echo -e "${YELLOW}[WARN]${NC} $*"; } | ||||||
|
|
||||||
| # ── Detect if running locally (SSH to EC2) or on EC2 directly ──────────────── | ||||||
| if [[ -f "$CONFIG_FILE" ]]; then | ||||||
| # Running locally — SSH to EC2 and run backup there | ||||||
| # shellcheck source=/dev/null | ||||||
| source "$CONFIG_FILE" | ||||||
| [[ -n "${EC2_IP:-}" ]] || { echo "EC2_IP not set"; exit 1; } | ||||||
| SSH_OPTS="-i ${KEY_FILE} -o StrictHostKeyChecking=no" | ||||||
|
||||||
| SSH_OPTS="-i ${KEY_FILE} -o StrictHostKeyChecking=no" | |
| SSH_OPTS="-i ${KEY_FILE} -o StrictHostKeyChecking=accept-new" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RUN npm testwill fail becausepackage.jsoncurrently has notestscript defined. Either add atestscript (and any required test tooling) or remove this build step sodocker buildsucceeds.