Skip to content

cicd: add cicd workflows #6

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

Merged
merged 6 commits into from
Mar 30, 2025
Merged
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
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Version control
.git
.gitignore

# Dependencies
node_modules
npm-debug.log

# Environment files
.env
.env.*

# Development files
.vscode
.idea
*.test.ts
*.spec.ts

# Docker files
Dockerfile
docker-compose.yml
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Build stage
FROM node:18 AS builder

WORKDIR /app

# Copy all source files first
COPY . .

# Install dependencies and build
RUN npm ci && \
npm run build

# Production stage
FROM node:18

# Create app directory and non-root user with proper home directory
WORKDIR /app
RUN groupadd -r appgroup && \
useradd -r -g appgroup -m -d /home/appuser appuser && \
chown -R appuser:appgroup /app

# Copy package files and install production dependencies
COPY package*.json tsconfig.json ./
ENV NODE_ENV=production

# Install production dependencies and rebuild native modules
RUN npm ci --omit=dev --ignore-scripts && \
npm rebuild && \
chown -R appuser:appgroup /app

# Copy built files from builder stage
COPY --from=builder /app/dist ./dist
RUN chown -R appuser:appgroup /app/dist

# Set environment variables
ENV LOG_LEVEL=info
ENV HOME=/home/appuser

# Switch to non-root user
USER appuser

# Use ENTRYPOINT and CMD to allow argument overrides
ENTRYPOINT ["npm", "start", "--"]
CMD []
14 changes: 11 additions & 3 deletions src/transports/sse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class SSETransport {
constructor(options: SSETransportOptions = {}) {
this.options = {
port: options.port || 3001,
host: options.host || 'localhost',
host: options.host || '0.0.0.0', // Changed from localhost to 0.0.0.0
keepAliveInterval: options.keepAliveInterval || 30000 // Default: 30 seconds
};

Expand All @@ -31,6 +31,14 @@ export class SSETransport {
allowedHeaders: ['Content-Type']
}));

// Health check endpoint
this.app.get('/healthz', (_req: Request, res: Response) => {
res.status(200).json({
status: 'ok',
timestamp: new Date().toISOString()
});
});

// SSE endpoint
this.app.get('/sse', (req: Request, res: Response) => {
const transport = new SSEServerTransport('/messages', res);
Expand Down Expand Up @@ -86,7 +94,7 @@ export class SSETransport {
async start(server: Server): Promise<void> {
this.server = server;
const port = this.options.port || 3001;
const host = this.options.host || 'localhost';
const host = this.options.host || '0.0.0.0'; // Changed from localhost to 0.0.0.0

return new Promise((resolve) => {
this.app.listen(port, host, () => {
Expand All @@ -95,4 +103,4 @@ export class SSETransport {
});
});
}
}
}
Loading