blumenjs 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -555,6 +555,67 @@ export function Link({ href, children, onClick, target, ...rest }: LinkProps) {
555
555
 
556
556
  export default Link;
557
557
  `;
558
+ var DOCKERFILE = `# \u2500\u2500 Stage 1: Build Go server \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
559
+ FROM golang:1.22-alpine AS go-builder
560
+ WORKDIR /app
561
+ COPY go-server/ go-server/
562
+ WORKDIR /app/go-server
563
+ RUN go build -o /app/blumen-server main.go
564
+
565
+ # \u2500\u2500 Stage 2: Build Node SSR + client bundle \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
566
+ FROM node:20-alpine AS node-builder
567
+ WORKDIR /app
568
+ COPY package.json tsconfig.json webpack.config.js ./
569
+ COPY app/ app/
570
+ COPY node-ssr/ node-ssr/
571
+ COPY scripts/ scripts/
572
+ RUN npm install --production=false
573
+ RUN npx tsx scripts/generate-routes.ts
574
+ RUN npx webpack --mode production
575
+ RUN npx esbuild node-ssr/server.ts --bundle --platform=node --format=esm \\
576
+ --outfile=dist/ssr-server.js --external:react --external:react-dom
577
+
578
+ # \u2500\u2500 Stage 3: Production image \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
579
+ FROM node:20-alpine
580
+ RUN apk add --no-cache libc6-compat
581
+ WORKDIR /app
582
+
583
+ # Copy Go binary
584
+ COPY --from=go-builder /app/blumen-server ./blumen-server
585
+
586
+ # Copy Node SSR server + production deps
587
+ COPY --from=node-builder /app/dist/ ./dist/
588
+ COPY --from=node-builder /app/static/ ./static/
589
+ COPY --from=node-builder /app/node_modules/ ./node_modules/
590
+ COPY --from=node-builder /app/package.json ./
591
+
592
+ EXPOSE 3000 4000
593
+
594
+ # Start both services (Go on :3000, Node SSR on :4000)
595
+ CMD sh -c './blumen-server & NODE_ENV=production node dist/ssr-server.js'
596
+ `;
597
+ var DOCKER_COMPOSE = `services:
598
+ app:
599
+ build: .
600
+ ports:
601
+ - "3000:3000"
602
+ environment:
603
+ - NODE_ENV=production
604
+ restart: unless-stopped
605
+ healthcheck:
606
+ test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000"]
607
+ interval: 30s
608
+ timeout: 5s
609
+ retries: 3
610
+ start_period: 10s
611
+ `;
612
+ var DOCKERIGNORE = `node_modules
613
+ dist
614
+ static/js/bundle.js
615
+ .git
616
+ *.log
617
+ .DS_Store
618
+ `;
558
619
  function writeFile(base, relPath, content) {
559
620
  const fullPath = path2.join(base, relPath);
560
621
  fs3.mkdirSync(path2.dirname(fullPath), { recursive: true });
@@ -580,7 +641,11 @@ function getTemplateFiles(projectName) {
580
641
  ["go-server/main.go", readProjectFile("go-server/main.go")],
581
642
  ["scripts/generate-routes.ts", readProjectFile("scripts/generate-routes.ts")],
582
643
  // Placeholder
583
- ["static/js/.gitkeep", ""]
644
+ ["static/js/.gitkeep", ""],
645
+ // Docker support (production deployment)
646
+ ["Dockerfile", DOCKERFILE],
647
+ ["docker-compose.yml", DOCKER_COMPOSE],
648
+ [".dockerignore", DOCKERIGNORE]
584
649
  ];
585
650
  }
586
651
  async function create(projectName) {
@@ -303,6 +303,67 @@ export function Link({ href, children, onClick, target, ...rest }: LinkProps) {
303
303
 
304
304
  export default Link;
305
305
  `;
306
+ var DOCKERFILE = `# \u2500\u2500 Stage 1: Build Go server \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
307
+ FROM golang:1.22-alpine AS go-builder
308
+ WORKDIR /app
309
+ COPY go-server/ go-server/
310
+ WORKDIR /app/go-server
311
+ RUN go build -o /app/blumen-server main.go
312
+
313
+ # \u2500\u2500 Stage 2: Build Node SSR + client bundle \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
314
+ FROM node:20-alpine AS node-builder
315
+ WORKDIR /app
316
+ COPY package.json tsconfig.json webpack.config.js ./
317
+ COPY app/ app/
318
+ COPY node-ssr/ node-ssr/
319
+ COPY scripts/ scripts/
320
+ RUN npm install --production=false
321
+ RUN npx tsx scripts/generate-routes.ts
322
+ RUN npx webpack --mode production
323
+ RUN npx esbuild node-ssr/server.ts --bundle --platform=node --format=esm \\
324
+ --outfile=dist/ssr-server.js --external:react --external:react-dom
325
+
326
+ # \u2500\u2500 Stage 3: Production image \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
327
+ FROM node:20-alpine
328
+ RUN apk add --no-cache libc6-compat
329
+ WORKDIR /app
330
+
331
+ # Copy Go binary
332
+ COPY --from=go-builder /app/blumen-server ./blumen-server
333
+
334
+ # Copy Node SSR server + production deps
335
+ COPY --from=node-builder /app/dist/ ./dist/
336
+ COPY --from=node-builder /app/static/ ./static/
337
+ COPY --from=node-builder /app/node_modules/ ./node_modules/
338
+ COPY --from=node-builder /app/package.json ./
339
+
340
+ EXPOSE 3000 4000
341
+
342
+ # Start both services (Go on :3000, Node SSR on :4000)
343
+ CMD sh -c './blumen-server & NODE_ENV=production node dist/ssr-server.js'
344
+ `;
345
+ var DOCKER_COMPOSE = `services:
346
+ app:
347
+ build: .
348
+ ports:
349
+ - "3000:3000"
350
+ environment:
351
+ - NODE_ENV=production
352
+ restart: unless-stopped
353
+ healthcheck:
354
+ test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000"]
355
+ interval: 30s
356
+ timeout: 5s
357
+ retries: 3
358
+ start_period: 10s
359
+ `;
360
+ var DOCKERIGNORE = `node_modules
361
+ dist
362
+ static/js/bundle.js
363
+ .git
364
+ *.log
365
+ .DS_Store
366
+ `;
306
367
  function writeFile(base, relPath, content) {
307
368
  const fullPath = path2.join(base, relPath);
308
369
  fs2.mkdirSync(path2.dirname(fullPath), { recursive: true });
@@ -328,7 +389,11 @@ function getTemplateFiles(projectName) {
328
389
  ["go-server/main.go", readProjectFile("go-server/main.go")],
329
390
  ["scripts/generate-routes.ts", readProjectFile("scripts/generate-routes.ts")],
330
391
  // Placeholder
331
- ["static/js/.gitkeep", ""]
392
+ ["static/js/.gitkeep", ""],
393
+ // Docker support (production deployment)
394
+ ["Dockerfile", DOCKERFILE],
395
+ ["docker-compose.yml", DOCKER_COMPOSE],
396
+ [".dockerignore", DOCKERIGNORE]
332
397
  ];
333
398
  }
334
399
  async function create(projectName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blumenjs",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The React framework powered by Go. Lightning-fast SSR with the DX you deserve.",
5
5
  "type": "module",
6
6
  "bin": {