Refactor code structure for improved readability and maintainability
Build And Push Image / docker (push) Failing after 7s
Details
Build And Push Image / docker (push) Failing after 7s
Details
This commit is contained in:
parent
870be11f7f
commit
8d93f4cd2e
|
|
@ -16,15 +16,10 @@ jobs:
|
|||
username: ${{ vars.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Set Up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Build Docker Image
|
||||
run: |
|
||||
docker build -t ${{ vars.REGISTRY_HOST }}/${{ vars.REGISTRY_USERNAME }}/${{ vars.IMAGE_NAME }}:latest .
|
||||
|
||||
- name: Build And Push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
${{ vars.REGISTRY_HOST }}/${{ vars.REGISTRY_USERNAME }}/${{ vars.IMAGE_NAME }}:latest
|
||||
- name: Push Docker Image
|
||||
run: |
|
||||
docker push ${{ vars.REGISTRY_HOST }}/${{ vars.REGISTRY_USERNAME }}/${{ vars.IMAGE_NAME }}:latest
|
||||
|
|
|
|||
67
Dockerfile
67
Dockerfile
|
|
@ -1,57 +1,28 @@
|
|||
# Multi-stage build for MonacoUSA Portal
|
||||
# Stage 1: Builder
|
||||
FROM node:18-alpine AS builder
|
||||
ARG NODE_VERSION=20.10.0
|
||||
ARG PORT=6060
|
||||
|
||||
# Set working directory
|
||||
FROM node:${NODE_VERSION}-slim as base
|
||||
ENV NODE_ENV=production
|
||||
ENV NODE_OPTIONS=--max-old-space-size=8192
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install all dependencies (including dev dependencies for build)
|
||||
RUN npm install && npm cache clean --force
|
||||
|
||||
# Copy source code
|
||||
FROM base as build
|
||||
COPY package.json .
|
||||
COPY package-lock.json .
|
||||
RUN npm ci --production=false
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
RUN npm prune
|
||||
|
||||
# Stage 2: Runtime
|
||||
FROM node:18-alpine AS runtime
|
||||
FROM base as production
|
||||
ENV PORT=$PORT
|
||||
COPY --from=build /app/.output /app/.output
|
||||
|
||||
# Install dumb-init for proper signal handling
|
||||
RUN apk add --no-cache dumb-init
|
||||
# Add health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD curl -f http://localhost:6060/api/health || exit 1
|
||||
|
||||
# Create app user
|
||||
RUN addgroup -g 1001 -S nodejs
|
||||
RUN adduser -S nuxt -u 1001
|
||||
# Install curl for health check
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy built application from builder stage
|
||||
COPY --from=builder --chown=nuxt:nodejs /app/.output ./.output
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY --chown=nuxt:nodejs docker-entrypoint.sh ./
|
||||
RUN chmod +x docker-entrypoint.sh
|
||||
|
||||
# Create volume directory for persistent data
|
||||
RUN mkdir -p /app/data && chown nuxt:nodejs /app/data
|
||||
|
||||
# Switch to non-root user
|
||||
USER nuxt
|
||||
|
||||
# Expose port
|
||||
EXPOSE 6060
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
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", "--"]
|
||||
|
||||
# Start the application
|
||||
CMD ["./docker-entrypoint.sh"]
|
||||
CMD ["node", ".output/server/index.mjs"]
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue