@kithinji/pod 1.0.20 → 1.0.21

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.
package/dist/main.js CHANGED
@@ -4361,6 +4361,7 @@ async function dockerize(env = "prod") {
4361
4361
  } else {
4362
4362
  await setupDevelopment(cwd, projectName, selectedServices);
4363
4363
  }
4364
+ await createDeployfile(cwd, projectName);
4364
4365
  await writeEnvVars(cwd, selectedServices, env);
4365
4366
  printNextSteps(projectName, env, selectedServices);
4366
4367
  }
@@ -4541,6 +4542,108 @@ temp
4541
4542
  await fs9.writeFile(dockerfilePath, dockerfile);
4542
4543
  await fs9.writeFile(dockerignorePath, dockerignore);
4543
4544
  }
4545
+ async function createDeployfile(cwd, projectName) {
4546
+ const deployFile = `name: ${projectName}
4547
+ version: 1.0.0
4548
+
4549
+ targets:
4550
+ ec2:
4551
+ host: ec2-xx-xx-xxx-xxx.xx-xxxx-x.compute.amazonaws.com
4552
+ user: ubuntu
4553
+ keyPath: ~/xxxx.pem
4554
+ port: 22
4555
+ deployPath: /home/\${ubuntu}/app
4556
+
4557
+ operations:
4558
+ - name: "Setup swap space"
4559
+ type: ensure
4560
+ ensure:
4561
+ swap:
4562
+ size: 4G
4563
+
4564
+ - name: "Install Docker"
4565
+ type: ensure
4566
+ ensure:
4567
+ docker:
4568
+ version: "28.5.2"
4569
+ addUserToGroup: true
4570
+
4571
+ - name: "Create application directories"
4572
+ type: ensure
4573
+ ensure:
4574
+ directory:
4575
+ path: \${deployPath}
4576
+ owner: \${user}
4577
+
4578
+ - name: "Create backup directory"
4579
+ type: ensure
4580
+ ensure:
4581
+ directory:
4582
+ path: /home/\${ubuntu}/backups
4583
+ owner: \${user}
4584
+
4585
+ - name: "Stop running containers"
4586
+ type: action
4587
+ action:
4588
+ command: cd \${deployPath} && docker compose down 2>/dev/null || true
4589
+
4590
+ - name: "Sync application files"
4591
+ type: action
4592
+ action:
4593
+ rsync:
4594
+ source: ./
4595
+ destination: \${deployPath}/
4596
+ exclude:
4597
+ - node_modules/
4598
+ - .git/
4599
+ - "*.log"
4600
+ - .env.local
4601
+ - dist/
4602
+ - public/
4603
+
4604
+ - name: "Pull Docker images"
4605
+ type: action
4606
+ action:
4607
+ command: cd \${deployPath} && docker compose pull
4608
+
4609
+ - name: "Build and start containers"
4610
+ type: action
4611
+ action:
4612
+ command: cd \${deployPath} && docker compose up -d --build --remove-orphans
4613
+
4614
+ - name: "Wait for services to start"
4615
+ type: action
4616
+ action:
4617
+ command: sleep 10
4618
+
4619
+ - name: "Show container status"
4620
+ type: action
4621
+ action:
4622
+ command: cd \${deployPath} && docker compose ps
4623
+
4624
+ - name: "Show recent logs"
4625
+ type: action
4626
+ action:
4627
+ command: cd \${deployPath} && docker compose logs --tail=30
4628
+
4629
+ - name: "Cleanup old backups"
4630
+ type: action
4631
+ action:
4632
+ command: find /home/\${ubuntu}/backups -name "backup-*.tar.gz" -mtime +7 -delete
4633
+
4634
+ - name: "Cleanup Docker resources"
4635
+ type: action
4636
+ action:
4637
+ command: docker system prune -f --volumes
4638
+
4639
+ - name: "Verify containers are running"
4640
+ type: verify
4641
+ verify:
4642
+ command: cd \${deployPath} && docker compose ps | grep -q "Up"
4643
+ `;
4644
+ const deployFilePath = path12.join(cwd, "pod.deploy.yml");
4645
+ await fs9.writeFile(deployFilePath, deployFile);
4646
+ }
4544
4647
  async function setupProduction(cwd, projectName, services) {
4545
4648
  const compose = {
4546
4649
  services: {
@@ -4558,6 +4661,10 @@ async function setupProduction(cwd, projectName, services) {
4558
4661
  ],
4559
4662
  labels: [
4560
4663
  "traefik.enable=true",
4664
+ "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)",
4665
+ "traefik.http.routers.http-catchall.entrypoints=web",
4666
+ "traefik.http.routers.http-catchall.middlewares=redirect-to-https",
4667
+ "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https",
4561
4668
  "traefik.http.routers.dashboard.rule=Host(`traefik.${HOST}`)",
4562
4669
  "traefik.http.routers.dashboard.entrypoints=websecure",
4563
4670
  "traefik.http.routers.dashboard.tls.certresolver=myresolver",
@@ -5281,7 +5388,7 @@ async function handleVerify(op, shell, target) {
5281
5388
  // src/main.ts
5282
5389
  import chalk2 from "chalk";
5283
5390
  var program = new Command();
5284
- program.name("pod").description("Pod cli tool").version("1.0.20");
5391
+ program.name("pod").description("Pod cli tool").version("1.0.21");
5285
5392
  program.command("new <name>").description("Start a new Pod Project").action(async (name) => {
5286
5393
  await addNew(name);
5287
5394
  const appDir = path14.resolve(process.cwd(), name);