Update Dockerfile and docker-compose.yml to change application port to 6060; add health check endpoint. Add cookie dependency to package.json and create health check API endpoint.

This commit is contained in:
Matt 2025-08-06 14:57:19 +02:00
parent d0075f5b12
commit ae928bbb9b
5 changed files with 43 additions and 7 deletions

View File

@ -8,8 +8,8 @@ WORKDIR /app
# Copy package files # Copy package files
COPY package*.json ./ COPY package*.json ./
# Install dependencies # Install all dependencies (including dev dependencies for build)
RUN npm ci --only=production && npm cache clean --force RUN npm install && npm cache clean --force
# Copy source code # Copy source code
COPY . . COPY . .
@ -44,11 +44,11 @@ RUN mkdir -p /app/data && chown nuxt:nodejs /app/data
USER nuxt USER nuxt
# Expose port # Expose port
EXPOSE 3000 EXPOSE 6060
# Health check # Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/api/health', (r) => {r.statusCode === 200 ? process.exit(0) : process.exit(1)})" || exit 1 CMD node -e "require('http').get('http://localhost:6060/api/health', (r) => {r.statusCode === 200 ? process.exit(0) : process.exit(1)})" || exit 1
# Use dumb-init to handle signals properly # Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"] ENTRYPOINT ["dumb-init", "--"]

View File

@ -8,7 +8,7 @@ services:
container_name: monacousa-portal container_name: monacousa-portal
restart: unless-stopped restart: unless-stopped
ports: ports:
- "3000:3000" - "6060:6060"
volumes: volumes:
# Volume for persistent data (environment files, logs, etc.) # Volume for persistent data (environment files, logs, etc.)
- ./data:/app/data - ./data:/app/data
@ -18,7 +18,7 @@ services:
# Basic configuration # Basic configuration
- NODE_ENV=production - NODE_ENV=production
- NUXT_HOST=0.0.0.0 - NUXT_HOST=0.0.0.0
- NUXT_PORT=3000 - NUXT_PORT=6060
# Keycloak Configuration (override with your values) # Keycloak Configuration (override with your values)
- NUXT_KEYCLOAK_ISSUER=${KEYCLOAK_ISSUER:-https://auth.monacousa.org/realms/monacousa-portal} - NUXT_KEYCLOAK_ISSUER=${KEYCLOAK_ISSUER:-https://auth.monacousa.org/realms/monacousa-portal}
@ -50,7 +50,7 @@ services:
- WAIT_FOR_SERVICES=${WAIT_FOR_SERVICES:-false} - WAIT_FOR_SERVICES=${WAIT_FOR_SERVICES:-false}
healthcheck: healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/api/health', (r) => {r.statusCode === 200 ? process.exit(0) : process.exit(1)})"] test: ["CMD", "node", "-e", "require('http').get('http://localhost:6060/api/health', (r) => {r.statusCode === 200 ? process.exit(0) : process.exit(1)})"]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3

View File

@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"@nuxt/ui": "^3.2.0", "@nuxt/ui": "^3.2.0",
"@vite-pwa/nuxt": "^0.10.6", "@vite-pwa/nuxt": "^0.10.6",
"cookie": "^0.6.0",
"formidable": "^3.5.4", "formidable": "^3.5.4",
"mime-types": "^3.0.1", "mime-types": "^3.0.1",
"minio": "^8.0.5", "minio": "^8.0.5",
@ -23,6 +24,7 @@
"vuetify-nuxt-module": "^0.18.3" "vuetify-nuxt-module": "^0.18.3"
}, },
"devDependencies": { "devDependencies": {
"@types/cookie": "^0.6.0",
"@types/formidable": "^3.4.5", "@types/formidable": "^3.4.5",
"@types/mime-types": "^3.0.1", "@types/mime-types": "^3.0.1",
"@types/node": "^20.0.0" "@types/node": "^20.0.0"

29
server/api/health.get.ts Normal file
View File

@ -0,0 +1,29 @@
export default defineEventHandler(async (event) => {
try {
// Basic health check - can be expanded to check database, storage, etc.
const health = {
status: 'healthy',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
checks: {
server: 'healthy',
// Add more checks as needed
// database: await checkDatabase(),
// storage: await checkStorage(),
// auth: await checkAuth(),
},
};
return health;
} catch (error) {
throw createError({
statusCode: 503,
statusMessage: 'Service Unavailable',
data: {
status: 'unhealthy',
timestamp: new Date().toISOString(),
error: error instanceof Error ? error.message : 'Unknown error',
},
});
}
});

View File

@ -6,6 +6,9 @@ jobs:
docker: docker:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Login To Registry - name: Login To Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
@ -19,6 +22,8 @@ jobs:
- name: Build And Push - name: Build And Push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
file: ./Dockerfile
platforms: linux/amd64 platforms: linux/amd64
push: true push: true
tags: | tags: |