diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4af4093 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +Dockerfile +.dockerignore +*.js diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3567603 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:22-bookworm AS runner +WORKDIR /app +ENV NODE_ENV="production" +COPY package.json package-lock.json ./ +RUN npm install --omit=dev + +FROM runner AS builder +COPY . . +RUN npm install && npm run build && npm prune --omit=dev + +FROM runner +COPY --from=builder /app/dist /app +EXPOSE 3000 +ENTRYPOINT ["node", "src/server.js"] diff --git a/package.json b/package.json index 717f1d0..e007433 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,15 @@ "module": "src/server.ts", "type": "module", "scripts": { - "build": "tsc", + "build": "tsc && tsc-alias", "start": "tsx src/server.ts", "fmt": "dprint fmt" }, "devDependencies": { "@types/bcrypt": "^5.0.2", "@types/bun": "^1.0.4", - "@types/bcrypt": "^5.0.2", "dprint": "^0.46.2", + "tsc-alias": "^1.8.10", "tsx": "^4.7.0", "typescript": "^5.3.3" }, diff --git a/src/server.ts b/src/server.ts index 394d538..27635ad 100644 --- a/src/server.ts +++ b/src/server.ts @@ -3,7 +3,7 @@ import websocket, { WebSocket } from "@fastify/websocket"; import { Type, TypeBoxTypeProvider } from "@fastify/type-provider-typebox"; import Fastify, { FastifyReply } from "fastify"; import { nanoid } from "nanoid"; -import { allocateBuffer, getRunner } from "runner"; +import { allocateBuffer, getRunner } from "./runner"; import { Pull, Push } from "zeromq"; import { ChangeSet, Text } from "@codemirror/state"; import { Update, rebaseUpdates } from "@codemirror/collab"; @@ -632,4 +632,4 @@ async function forwardOutput() { } /* Lancer le serveur et la fonction forwardOutput sur le même thread en parallèle */ -await Promise.all([fastify.listen({ port: 3000 }), forwardOutput()]); +await Promise.all([fastify.listen({ port: 3000, host: '0.0.0.0' }), forwardOutput()]); diff --git a/tsconfig.json b/tsconfig.json index 2558e1d..4accc64 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,15 @@ { "compilerOptions": { "baseUrl": "./src", + "outDir": "./dist", "types": ["bun-types"], "lib": ["esnext"], "module": "esnext", "target": "esnext", - "moduleResolution": "bundler", - "noEmit": true, - "allowImportingTsExtensions": true, + "moduleResolution": "Node", + "noEmit": false, "moduleDetection": "force", "strict": true, @@ -18,5 +18,8 @@ "composite": true, "downlevelIteration": true, "allowSyntheticDefaultImports": true + }, + "tsc-alias": { + "resolveFullPaths": true } }