From ba2c2db56ce212ee696619e99430c64db0eaea96 Mon Sep 17 00:00:00 2001 From: Michael Thiesen Date: Thu, 17 Oct 2024 18:39:48 -0700 Subject: [PATCH] Updated Dockerfile and configs to use pnpm v9 and change the output file structure --- .gitignore | 1 + Dockerfile | 13 +++++++------ package.json | 3 +-- src/index.ts | 14 ++++++++++++++ tsconfig.json | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 src/index.ts diff --git a/.gitignore b/.gitignore index c2658d7..1eae0cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +dist/ node_modules/ diff --git a/Dockerfile b/Dockerfile index 8b36723..b08ce94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ -FROM node:16-slim AS build +FROM node:20-slim AS build COPY . /build WORKDIR /build -RUN npm install -g pnpm -RUN pnpm install --prod --frozen-lockfile -ENV NODE_ENV=production +RUN npm install -g pnpm@9 +RUN pnpm install --frozen-lockfile RUN pnpm run build FROM node:20-slim @@ -14,8 +13,10 @@ ENV NODE_ENV=production COPY --from=build /build/dist /app WORKDIR /app -RUN npm install -g pnpm +COPY package.json pnpm-lock.yaml ./ + +RUN npm install -g pnpm@9 RUN pnpm install --production EXPOSE 5888 -CMD ["node", "main.js"] +CMD ["node", "/app/index.js"] diff --git a/package.json b/package.json index 22a56ac..292ae58 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,9 @@ "name": "edgecontrol", "version": "0.0.0", "private": true, - "type": "module", "scripts": { "dev": "tsx watch src/index.ts", - "build": "tsc", + "build": "tsc --outDir dist src/index.ts", "typecheck": "tsc --noEmit", "lint": "biome lint .", "format": "biome format .", diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..eabe1b6 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,14 @@ +import { type HttpBindings, serve } from "@hono/node-server"; +import { Hono } from "hono"; + +const app = new Hono<{ Bindings: HttpBindings }>(); + +app.get("/", (c) => { + const resp = c.text("Hono meets Node.js"); + console.log(`${c.env.incoming.method} ${c.env.incoming.url}`); + return resp; +}); + +serve({ fetch: app.fetch, port: 5888 }, (info) => { + console.log(`Listening on http://localhost:${info.port}`); +}); diff --git a/tsconfig.json b/tsconfig.json index 1c41947..93f3c93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,6 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "baseUrl": ".", - "sourceMap": true + "sourceMap": false } }