chore: switch production container and docs to bun runtime
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
NODE_ENV=production
|
||||
PORT=3000
|
||||
STATE_FILE_PATH=/data/state.json
|
||||
LOG_LEVEL=info
|
||||
|
||||
# Webhook secrets
|
||||
X_WEBHOOK_SECRET=replace-me
|
||||
|
||||
10
Dockerfile
10
Dockerfile
@@ -1,4 +1,4 @@
|
||||
FROM node:22-alpine
|
||||
FROM oven/bun:1.3.5-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -6,7 +6,9 @@ ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV STATE_FILE_PATH=/data/state.json
|
||||
|
||||
COPY package.json ./
|
||||
COPY package.json bun.lock ./
|
||||
RUN bun install --frozen-lockfile --production
|
||||
|
||||
COPY src ./src
|
||||
COPY README.md ./README.md
|
||||
COPY spec.md ./spec.md
|
||||
@@ -14,6 +16,6 @@ COPY spec.md ./spec.md
|
||||
EXPOSE 3000
|
||||
VOLUME ["/data"]
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD node -e "fetch('http://127.0.0.1:'+process.env.PORT+'/health').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
|
||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD bun -e "fetch('http://127.0.0.1:'+process.env.PORT+'/health').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
|
||||
|
||||
CMD ["node", "src/server.js"]
|
||||
CMD ["bun", "src/server.js"]
|
||||
|
||||
@@ -360,9 +360,10 @@ This repository now contains a deployable production-style app (single container
|
||||
- `GET /health`
|
||||
|
||||
### Local commands
|
||||
1. `npm test`
|
||||
2. `npm run start`
|
||||
3. `npm run dev`
|
||||
1. `bun test`
|
||||
2. `bun run lint`
|
||||
3. `bun run start`
|
||||
4. `bun run dev`
|
||||
|
||||
### Environment variables
|
||||
Use `.env.example` as the source of truth.
|
||||
|
||||
@@ -6,15 +6,17 @@ const fs = require("node:fs");
|
||||
|
||||
test("Dockerfile contains production container essentials", () => {
|
||||
const dockerfile = fs.readFileSync("Dockerfile", "utf8");
|
||||
assert.match(dockerfile, /FROM node:22-alpine/);
|
||||
assert.match(dockerfile, /FROM oven\/bun:1\.3\.5-alpine/);
|
||||
assert.match(dockerfile, /EXPOSE 3000/);
|
||||
assert.match(dockerfile, /STATE_FILE_PATH=\/data\/state\.json/);
|
||||
assert.match(dockerfile, /bun install --frozen-lockfile --production/);
|
||||
assert.match(dockerfile, /HEALTHCHECK/);
|
||||
assert.match(dockerfile, /CMD \["node", "src\/server\.js"\]/);
|
||||
assert.match(dockerfile, /CMD \["bun", "src\/server\.js"\]/);
|
||||
});
|
||||
|
||||
test("env example includes required webhook and credit settings", () => {
|
||||
const envFile = fs.readFileSync(".env.example", "utf8");
|
||||
assert.match(envFile, /LOG_LEVEL=/);
|
||||
assert.match(envFile, /X_WEBHOOK_SECRET=/);
|
||||
assert.match(envFile, /POLAR_WEBHOOK_SECRET=/);
|
||||
assert.match(envFile, /INCLUDED_CHARS=/);
|
||||
|
||||
Reference in New Issue
Block a user