Skip to content

Commit 582ff1d

Browse files
committed
fix demo
1 parent 2f9d739 commit 582ff1d

3 files changed

Lines changed: 28 additions & 13 deletions

File tree

Dockerfile.demo

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,9 @@ COPY . .
1313

1414
RUN pnpm -r build
1515

16-
FROM node:20-alpine AS runner
17-
WORKDIR /app
18-
19-
ENV NODE_ENV=production
20-
ENV PORT=4173
16+
FROM nginx:1.27-alpine AS runner
2117

22-
RUN corepack enable && corepack prepare pnpm@10.30.3 --activate
23-
24-
COPY --from=build /app /app
18+
COPY deploy/nginx-state-layers.conf /etc/nginx/conf.d/default.conf
19+
COPY --from=build /app/apps/demo/dist /usr/share/nginx/html/state-layers
2520

2621
EXPOSE 4173
27-
28-
CMD ["sh", "-c", "pnpm --filter @protohiro/state-layers-demo preview --host 0.0.0.0 --port ${PORT:-4173}"]

apps/demo/vite.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { fileURLToPath, URL } from "node:url";
22
import { defineConfig } from "vite";
33
import react from "@vitejs/plugin-react";
44

5-
export default defineConfig({
6-
base: "/state-layers/",
5+
export default defineConfig(({ command }) => ({
6+
base: command === "build" ? "/state-layers/" : "/",
77
plugins: [react()],
88
server: {
99
port: 4173
@@ -18,4 +18,4 @@ export default defineConfig({
1818
"@protohiro/state-layers": fileURLToPath(new URL("../../packages/react/src/index.ts", import.meta.url))
1919
}
2020
}
21-
});
21+
}));

deploy/nginx-state-layers.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 4173;
3+
server_name _;
4+
5+
root /usr/share/nginx/html;
6+
7+
location = /state-layers {
8+
return 301 /state-layers/;
9+
}
10+
11+
location /state-layers/assets/ {
12+
try_files $uri =404;
13+
}
14+
15+
location /state-layers/ {
16+
try_files $uri $uri/ /state-layers/index.html;
17+
}
18+
19+
location / {
20+
return 404;
21+
}
22+
}

0 commit comments

Comments
 (0)