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:
parent
d0075f5b12
commit
ae928bbb9b
|
|
@ -8,8 +8,8 @@ WORKDIR /app
|
|||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production && npm cache clean --force
|
||||
# Install all dependencies (including dev dependencies for build)
|
||||
RUN npm install && npm cache clean --force
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
|
@ -44,11 +44,11 @@ RUN mkdir -p /app/data && chown nuxt:nodejs /app/data
|
|||
USER nuxt
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
EXPOSE 6060
|
||||
|
||||
# Health check
|
||||
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
|
||||
ENTRYPOINT ["dumb-init", "--"]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ services:
|
|||
container_name: monacousa-portal
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "6060:6060"
|
||||
volumes:
|
||||
# Volume for persistent data (environment files, logs, etc.)
|
||||
- ./data:/app/data
|
||||
|
|
@ -18,7 +18,7 @@ services:
|
|||
# Basic configuration
|
||||
- NODE_ENV=production
|
||||
- NUXT_HOST=0.0.0.0
|
||||
- NUXT_PORT=3000
|
||||
- NUXT_PORT=6060
|
||||
|
||||
# Keycloak Configuration (override with your values)
|
||||
- NUXT_KEYCLOAK_ISSUER=${KEYCLOAK_ISSUER:-https://auth.monacousa.org/realms/monacousa-portal}
|
||||
|
|
@ -50,7 +50,7 @@ services:
|
|||
- WAIT_FOR_SERVICES=${WAIT_FOR_SERVICES:-false}
|
||||
|
||||
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
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"dependencies": {
|
||||
"@nuxt/ui": "^3.2.0",
|
||||
"@vite-pwa/nuxt": "^0.10.6",
|
||||
"cookie": "^0.6.0",
|
||||
"formidable": "^3.5.4",
|
||||
"mime-types": "^3.0.1",
|
||||
"minio": "^8.0.5",
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
"vuetify-nuxt-module": "^0.18.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cookie": "^0.6.0",
|
||||
"@types/formidable": "^3.4.5",
|
||||
"@types/mime-types": "^3.0.1",
|
||||
"@types/node": "^20.0.0"
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -6,6 +6,9 @@ jobs:
|
|||
docker:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login To Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
|
|
@ -19,6 +22,8 @@ jobs:
|
|||
- name: Build And Push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
|
|
|
|||
Loading…
Reference in New Issue