forked from tas/major_tom
Add proper Containerfile and update Makefile to include the web shell
This commit is contained in:
@@ -1,3 +1,20 @@
|
|||||||
FROM scratch
|
# JNR Web — static file server for the Emscripten build
|
||||||
ENTRYPOINT ["/game.wasm"]
|
#
|
||||||
COPY /src/dist-web/jnr.wasm /game.wasm
|
# Prerequisites:
|
||||||
|
# make web (produces dist-web/)
|
||||||
|
#
|
||||||
|
# Build:
|
||||||
|
# podman build -t jnr-web .
|
||||||
|
# docker build -t jnr-web .
|
||||||
|
#
|
||||||
|
# Run locally:
|
||||||
|
# podman run --rm -p 8080:80 jnr-web
|
||||||
|
# Then visit http://localhost:8080
|
||||||
|
#
|
||||||
|
# Deploy to k3s:
|
||||||
|
# podman save jnr-web | sudo k3s ctr images import -
|
||||||
|
# sudo k3s kubectl apply -f k8s/
|
||||||
|
|
||||||
|
FROM docker.io/joseluisq/static-web-server:2
|
||||||
|
|
||||||
|
COPY dist-web/ /public/
|
||||||
|
|||||||
29
Makefile
29
Makefile
@@ -76,7 +76,7 @@ SRC_ALL := $(SRC_ENGINE) $(SRC_GAME) $(SRC_MAIN)
|
|||||||
OBJ_ALL := $(SRC_ALL:src/%.c=$(OBJ_DIR)/%.o)
|
OBJ_ALL := $(SRC_ALL:src/%.c=$(OBJ_DIR)/%.o)
|
||||||
|
|
||||||
# ── Targets ─────────────────────────────────────
|
# ── Targets ─────────────────────────────────────
|
||||||
.PHONY: all clean run debug windows deploy serve web web-serve
|
.PHONY: all clean run debug windows deploy serve web web-serve k8s
|
||||||
|
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
|
|
||||||
@@ -117,6 +117,7 @@ debug:
|
|||||||
web:
|
web:
|
||||||
@mkdir -p dist-web
|
@mkdir -p dist-web
|
||||||
$(MAKE) WASM=1 all
|
$(MAKE) WASM=1 all
|
||||||
|
@cp dist-web/jnr.html dist-web/index.html
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Web build ready in dist-web/"
|
@echo "Web build ready in dist-web/"
|
||||||
@echo "Serve with: make web-serve"
|
@echo "Serve with: make web-serve"
|
||||||
@@ -190,3 +191,29 @@ quick:
|
|||||||
@rsync -a --delete assets/ $(WIN_DIST)/assets/ 2>/dev/null || cp -r assets $(WIN_DIST)/
|
@rsync -a --delete assets/ $(WIN_DIST)/assets/ 2>/dev/null || cp -r assets $(WIN_DIST)/
|
||||||
@cd $(WIN_DIST) && zip -qr ../$(DEPLOY_ZIP) .
|
@cd $(WIN_DIST) && zip -qr ../$(DEPLOY_ZIP) .
|
||||||
@echo "Updated $(DEPLOY_ZIP)"
|
@echo "Updated $(DEPLOY_ZIP)"
|
||||||
|
|
||||||
|
# ── Kubernetes (k3s) deployment ─────────────────
|
||||||
|
# Builds the web version, packages it into a container image,
|
||||||
|
# imports it into k3s, and applies the manifests.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# make k8s Build + deploy to local k3s
|
||||||
|
#
|
||||||
|
K8S_IMAGE := jnr-web
|
||||||
|
K8S_TAG := latest
|
||||||
|
|
||||||
|
k8s: web
|
||||||
|
@echo ""
|
||||||
|
@echo "Building container image $(K8S_IMAGE):$(K8S_TAG)..."
|
||||||
|
@command -v podman >/dev/null 2>&1 && \
|
||||||
|
podman build -t $(K8S_IMAGE):$(K8S_TAG) . || \
|
||||||
|
docker build -t $(K8S_IMAGE):$(K8S_TAG) .
|
||||||
|
@echo "Importing image into k3s..."
|
||||||
|
@command -v podman >/dev/null 2>&1 && \
|
||||||
|
podman save $(K8S_IMAGE):$(K8S_TAG) | sudo k3s ctr images import - || \
|
||||||
|
docker save $(K8S_IMAGE):$(K8S_TAG) | sudo k3s ctr images import -
|
||||||
|
@echo "Applying manifests..."
|
||||||
|
@sudo k3s kubectl apply -f k8s/
|
||||||
|
@echo ""
|
||||||
|
@echo "Deployed. Check status with:"
|
||||||
|
@echo " sudo k3s kubectl get pods -l app=jnr-web"
|
||||||
|
|||||||
Reference in New Issue
Block a user