Add Docker image and compose for Needle web exports
Serve production Vite dist with nginx; optional SampleScene profile. Made-with: Cursor
This commit is contained in:
25
.dockerignore
Normal file
25
.dockerignore
Normal file
@@ -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
|
||||
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@@ -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
|
||||
Binary file not shown.
23
docker-compose.yml
Normal file
23
docker-compose.yml
Normal file
@@ -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
|
||||
20
docker/nginx-default.conf
Normal file
20
docker/nginx-default.conf
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user