Skip to content
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
35 changes: 30 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
FROM node:20-alpine AS build
LABEL MAINTAINER Gaute Rønningen <Gaute.Ronningen@nlb.no> <http://www.nlb.no/>

# Install pnpm
RUN npm install -g pnpm

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json ./
COPY yarn.lock ./
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./

# Install dependencies for production
RUN yarn
RUN pnpm install --frozen-lockfile --prod

# Bundle app source
COPY . .

FROM node:20-alpine AS runner
COPY --from=build /usr/src/app .
LABEL MAINTAINER Gaute Rønningen <Gaute.Ronningen@nlb.no> <http://www.nlb.no/>

# Install pnpm in runner stage
RUN npm install -g pnpm

# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001

# Set working directory
WORKDIR /usr/src/app

# Copy built application from build stage
COPY --from=build --chown=nodejs:nodejs /usr/src/app .

# Switch to non-root user
USER nodejs

# Expose ports
EXPOSE 80 443
HEALTHCHECK --interval=30s --timeout=10s --start-period=1m CMD http_proxy="" https_proxy="" curl --fail http://${HOST-0.0.0.0}:${PORT:-80}/health || exit 1

# Health check with improved configuration
HEALTHCHECK --interval=30s --timeout=10s --start-period=1m --retries=3 \
CMD http_proxy="" https_proxy="" curl --fail http://${HOST:-0.0.0.0}:${PORT:-80}/health || exit 1

# Start the application
CMD [ "node", "src/index.js" ]
59 changes: 59 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const js = require('@eslint/js');
const globals = require('globals');

module.exports = [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
...globals.jest,
testUtils: 'readonly'
}
},
rules: {
// Error handling
'no-console': 'warn',
'no-debugger': 'error',

// Code quality
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-undef': 'error',
'no-redeclare': 'error',
'no-unreachable': 'error',

// Best practices
'eqeqeq': ['error', 'always'],
'curly': ['error', 'all'],
'no-eval': 'error',
'no-implied-eval': 'error',
'no-new-func': 'error',
'no-script-url': 'error',

// Styling
'indent': ['error', 2],
'quotes': ['error', 'single', { avoidEscape: true }],
'semi': ['error', 'always'],
'comma-dangle': ['error', 'never'],
'no-trailing-spaces': 'error',
'eol-last': 'error',

// Complexity
'complexity': ['warn', 10],
'max-depth': ['warn', 4],
'max-lines': ['warn', 300],
'max-params': ['warn', 5]
}
},
{
ignores: [
'node_modules/',
'coverage/',
'dist/',
'build/',
'*.min.js'
]
}
];
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@
"mathjax-full": "^3.2.2",
"mathml-to-asciimath": "^1.4.0",
"mathml-to-latex": "^1.5.0",
"pino-multi-stream": "^6.0.0",
"pino-papertrail": "^2.1.0",
"tough-cookie": "^5.1.2",
"x2js": "^3.4.4",
"xml": "^1.0.1"
},
"devDependencies": {
"@eslint/js": "^9.32.0",
"@types/jest": "^30.0.0",
"complexity-report": "2.0.0-alpha",
"eslint": "^8.57.0",
"eslint": "^9.32.0",
"eslint-scope": "^8.4.0",
"espree": "^10.4.0",
"globals": "^16.3.0",
"jest": "^30.0.5",
"nodemon": "^3.1.10",
"supertest": "^7.1.4"
Expand Down
Loading
Loading