-
Notifications
You must be signed in to change notification settings - Fork 0
feat: regent mothership #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
14d1966
a7934e5
6fc2912
4c1dddb
78f40ea
a792fcc
afb3475
ffa468a
6610ecf
1dfd734
717bce6
b3c9add
77041ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| node_modules | ||
| dist | ||
| .git | ||
| .gitignore | ||
| *.md | ||
| .env* | ||
| data/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| PORT=3001 | ||
| JWT_SECRET=change-me-to-a-random-string | ||
| DB_PATH=./data/mothership.db | ||
| LOG_LEVEL=info | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| node_modules/ | ||
| dist/ | ||
| data/*.db | ||
| data/*.db-wal | ||
| data/*.db-shm | ||
| .env |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| {$DOMAIN:localhost} { | ||
| reverse_proxy mothership:3001 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Multi-stage build for Regent Mothership | ||
|
|
||
| FROM node:22-slim AS build | ||
| WORKDIR /app | ||
| COPY package.json package-lock.json ./ | ||
| RUN npm ci | ||
| COPY tsconfig.json ./ | ||
| COPY src/ ./src/ | ||
| RUN npx tsc | ||
|
|
||
| FROM node:22-slim | ||
| RUN addgroup --system mothership && adduser --system --ingroup mothership mothership | ||
| WORKDIR /app | ||
| COPY package.json package-lock.json ./ | ||
| RUN npm ci --omit=dev && chown -R mothership:mothership /app | ||
| COPY --from=build --chown=mothership:mothership /app/dist/ ./dist/ | ||
| COPY --chown=mothership:mothership src/db/migrations/ ./dist/db/migrations/ | ||
|
|
||
| ENV PORT=3001 | ||
| ENV DB_PATH=/data/mothership.db | ||
| ENV LOG_LEVEL=info | ||
| VOLUME /data | ||
|
|
||
| RUN mkdir -p /data && chown mothership:mothership /data | ||
|
|
||
| USER mothership | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correctness: Running as the non-root user 🤖 AI Agent Prompt for Cursor/Windsurf
|
||
| EXPOSE 3001 | ||
| CMD ["node", "dist/index.js"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| services: | ||
| mothership: | ||
| build: . | ||
| ports: | ||
| - "3001:3001" | ||
| volumes: | ||
| - mothership-data:/data | ||
| environment: | ||
| - JWT_SECRET=${JWT_SECRET:?JWT_SECRET is required} | ||
| - NODE_ENV=production | ||
| - DB_PATH=/data/mothership.db | ||
| - LOG_LEVEL=info | ||
| healthcheck: | ||
| test: ["CMD", "node", "-e", "fetch('http://localhost:3001/api/v1/health').then(r=>process.exit(r.ok?0:1))"] | ||
| interval: 30s | ||
| timeout: 5s | ||
| retries: 3 | ||
| restart: unless-stopped | ||
|
|
||
| caddy: | ||
| image: caddy:2-alpine | ||
| ports: | ||
| - "80:80" | ||
| - "443:443" | ||
| volumes: | ||
| - ./Caddyfile:/etc/caddy/Caddyfile | ||
| - caddy-data:/data | ||
| - caddy-config:/config | ||
| depends_on: | ||
| mothership: | ||
| condition: service_healthy | ||
| restart: unless-stopped | ||
|
|
||
| volumes: | ||
| mothership-data: | ||
| caddy-data: | ||
| caddy-config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's good practice to provide a placeholder secret in an example file, it's crucial to ensure a strong, unique secret is used in production. The current implementation in
src/config.tsfalls back to a weak, hardcoded secret if the environment variable is not set. This is a significant security risk. I've added a separate comment insrc/config.tswith a suggestion to enforce setting a secret in production environments.