diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..822395b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +# Git / IDE +.git +.gitignore +**/.cursor +**/.vs +.idea + +# Unity (not needed to build Needle web bundle) +Library/ +Temp/ +Logs/ +UserSettings/ +MemoryCaptures/ +Recordings/ +obj/ + +# Host-side Node (reinstalled in container) +**/node_modules/ + +# Build output (rebuilt in container) +**/Needle/*/dist/ + +# OS +.DS_Store +Thumbs.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e1a56fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Needle Engine web export (Vite) → static nginx +# +# Prerequisites before `docker build`: +# - Export your scene from Unity so Needle/MenuScene (or SampleScene) contains: +# - src/generated/ (gen.js, register_types, etc.) +# - assets/ with your .glb and any files the Vite build copies +# - `npm run build` should succeed locally for the same NEEDLE_APP. +# +# Build needs network: Needle's build may verify license against needle.tools. + +FROM node:22-alpine AS build +WORKDIR /build + +ARG NEEDLE_APP=MenuScene +ENV NEEDLE_APP=${NEEDLE_APP} + +COPY Needle/${NEEDLE_APP}/package.json Needle/${NEEDLE_APP}/package-lock.json ./ +RUN npm ci + +COPY Needle/${NEEDLE_APP}/ ./ + +RUN npm run build + +FROM nginx:1.27-alpine AS runtime + +COPY --from=build /build/dist /usr/share/nginx/html +COPY docker/nginx-default.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ + CMD wget -q -O /dev/null http://127.0.0.1/ || exit 1 diff --git a/Needle/MenuScene/include/poster.webp b/Needle/MenuScene/include/poster.webp index fdd8fe7..749fd3c 100644 --- a/Needle/MenuScene/include/poster.webp +++ b/Needle/MenuScene/include/poster.webp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51b589c952b559ac6231c3174a5bf38d450919889670b6920de1e18dab2375ee -size 66031 +oid sha256:aa2a970d9cbc1163c124fea1d4084c8f5eb5f13a917b6f87ad390cdeb351dfd2 +size 10228 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..40f541f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +services: + # Default: Needle/MenuScene → http://localhost:8080 + menu: + build: + context: . + dockerfile: Dockerfile + args: + NEEDLE_APP: MenuScene + ports: + - "8080:80" + restart: unless-stopped + + # Optional: docker compose --profile sample up --build + sample: + profiles: ["sample"] + build: + context: . + dockerfile: Dockerfile + args: + NEEDLE_APP: SampleScene + ports: + - "8081:80" + restart: unless-stopped diff --git a/docker/nginx-default.conf b/docker/nginx-default.conf new file mode 100644 index 0000000..5e1b2c8 --- /dev/null +++ b/docker/nginx-default.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # SPA / static Needle export + location / { + try_files $uri $uri/ /index.html; + } + + # wasm / glb / long cache for hashed assets (optional) + location ~* \.(wasm|glb|png|jpg|jpeg|webp|ico|svg)$ { + try_files $uri =404; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + + gzip on; + gzip_types text/css application/javascript application/json image/svg+xml; +}