Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
41 changes: 41 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# NodeJsVoip Server Configuration
# Copy this file to .env and customize the values for your environment

# Server Ports
# HTTPS port (default: 443)
SSL_PORT=443

# HTTP port for redirect to HTTPS (default: 80)
HTTP_PORT=80

# SSL Certificate Paths
# Path to SSL private key (default: ./cert/key.pem)
PRIVATE_KEY_PATH=./cert/key.pem

# Path to SSL certificate (default: ./cert/cert.pem)
CERTIFICATE_PATH=./cert/cert.pem

# Node Environment
# Options: development, production
NODE_ENV=production

# Socket.IO Configuration
# CORS origin (default: "*" allows all origins)
# For production, set to your specific domain(s)
CORS_ORIGIN=*

# Socket.IO ping timeout in milliseconds (default: 60000)
PING_TIMEOUT=60000

# Socket.IO ping interval in milliseconds (default: 25000)
PING_INTERVAL=25000

# Application Settings
# Enable debug logging (default: false)
DEBUG=false

# Maximum number of concurrent rooms (default: unlimited)
# MAX_ROOMS=100

# Maximum users per room (default: unlimited)
# MAX_USERS_PER_ROOM=50
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
/node_modules
/package-lock.json

# Environment variables
.env

# IDE files
.vscode/
.idea/

# Logs
*.log
npm-debug.log*
45 changes: 36 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
FROM node:boron
FROM node:20-alpine

MAINTAINER rofl256
LABEL maintainer="Suhail Taj Shaik"
LABEL description="NodeJsVoip - WebSocket-based VOIP application"

# Create app directory
RUN mkdir -p /opt/app
WORKDIR /opt/app

# Install app dependencies
COPY ./package.json /opt/app
RUN npm install
# Copy package files
COPY package*.json ./

# Install production dependencies only
RUN npm ci --only=production && \
npm cache clean --force

# Bundle app source
COPY . /opt/app
COPY . .

# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /opt/app

# Switch to non-root user
USER nodejs

# Environment variables with defaults
ENV SSL_PORT=443 \
HTTP_PORT=80 \
NODE_ENV=production \
PRIVATE_KEY_PATH=./cert/key.pem \
CERTIFICATE_PATH=./cert/cert.pem \
CORS_ORIGIN=* \
PING_TIMEOUT=60000 \
PING_INTERVAL=25000 \
DEBUG=false

# Expose ports
EXPOSE ${HTTP_PORT} ${SSL_PORT}

EXPOSE 80
EXPOSE 443
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:${HTTP_PORT}/', (res) => { process.exit(res.statusCode === 301 ? 0 : 1); })"

# Start the application
CMD [ "npm", "start" ]
Loading