Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ FROM node:22-alpine

WORKDIR /app

# Install wget for health check
RUN apk add --no-cache wget

# Copy package files first for better layer caching
COPY package*.json ./
RUN npm install --production

# Copy source
COPY . .

# Create non-root user for security
RUN addgroup -g 1001 crucix && adduser -D -u 1001 -G crucix crucix && chown -R crucix:crucix /app
USER crucix

# Default port (override with -e PORT=xxxx)
EXPOSE 3117

# Health check
HEALTHCHECK --interval=60s --timeout=10s --retries=3 \
CMD wget -qO- http://localhost:3117/api/health || exit 1
HEALTHCHECK --interval=60s --timeout=10s --retries=3 CMD wget -qO- http://localhost:3117/api/health || exit 1

CMD ["node", "server.mjs"]
12 changes: 11 additions & 1 deletion crucix.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

import './apis/utils/env.mjs'; // Load .env first

// Security: validate PORT is numeric and in safe range
function validatePort(val) {
const port = parseInt(val);
if (isNaN(port) || port < 1024 || port > 65535) {
console.warn('[Crucix] Invalid PORT, using default 3117');
return 3117;
}
return port;
}

export default {
port: parseInt(process.env.PORT) || 3117,
port: validatePort(process.env.PORT),
refreshIntervalMinutes: parseInt(process.env.REFRESH_INTERVAL_MINUTES) || 15,

llm: {
Expand Down