Skip to content

Commit

Permalink
Updated Dockerfile and configs to use pnpm v9 and change the output f…
Browse files Browse the repository at this point in the history
…ile structure
  • Loading branch information
micthiesen committed Oct 18, 2024
1 parent 527ed5c commit ba2c2db
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
node_modules/
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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}`);
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"sourceMap": true
"sourceMap": false
}
}

0 comments on commit ba2c2db

Please sign in to comment.