From c4d816086af4c7a35762e6b91b97ee2f48c79bdd Mon Sep 17 00:00:00 2001 From: mukeshs Date: Thu, 16 Oct 2025 19:33:59 +0530 Subject: [PATCH] docker update --- docker-compose.yml | 60 ++++++++++++++++++--------------- fuse-starter-v20.0.0/Dockerfile | 22 +++++++++++- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 64d85ba..8576d28 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,32 +1,6 @@ version: "3.9" services: - frontend: - build: - context: ./fuse-starter-v20.0.0 - container_name: vending-frontend - ports: - - "8086:80" - depends_on: - - backend - restart: always - - backend: - build: - context: ./Machine-Backend - container_name: vending-backend - env_file: - - ./Machine-Backend/.env - ports: - - "8087:5000" - volumes: - - ./Machine-Backend:/app - depends_on: - - db - restart: always - command: > - sh -c "python seed_user.py && gunicorn --bind 0.0.0.0:5000 run:app" - db: image: mysql:8.0 container_name: vending-db @@ -40,6 +14,38 @@ services: - "3307:3306" volumes: - mysql_data:/var/lib/mysql + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + timeout: 5s + retries: 10 + + backend: + build: + context: ./Machine-Backend + container_name: vending-backend + env_file: + - ./Machine-Backend/.env + ports: + - "8087:5000" + volumes: + - ./Machine-Backend:/app + depends_on: + db: + condition: service_healthy + restart: always + command: > + sh -c "python seed_user.py && gunicorn --bind 0.0.0.0:5000 run:app" + + frontend: + build: + context: ./fuse-starter-v20.0.0 + dockerfile: Dockerfile + container_name: vending-frontend + ports: + - "8086:80" + depends_on: + - backend + restart: always volumes: - mysql_data: + mysql_data: \ No newline at end of file diff --git a/fuse-starter-v20.0.0/Dockerfile b/fuse-starter-v20.0.0/Dockerfile index e5cbfb9..d140e7c 100644 --- a/fuse-starter-v20.0.0/Dockerfile +++ b/fuse-starter-v20.0.0/Dockerfile @@ -1,17 +1,37 @@ # Stage 1: Build Angular application FROM node:18-alpine AS builder + WORKDIR /app +# Copy package files COPY package*.json ./ + +# Install dependencies with legacy peer deps RUN npm ci --legacy-peer-deps +# Copy all source files COPY . . -# Development build (much faster - 2-3 minutes) +# Build the application (development mode for faster builds) RUN npm run build # Stage 2: Serve with Nginx FROM nginx:alpine AS production + +# Copy built files - check your actual output directory name +# It might be 'fuse-angular' or 'fuse-starter-v20.0.0' COPY --from=builder /app/dist/fuse-angular /usr/share/nginx/html + +# Custom nginx configuration for Angular routing +RUN echo 'server { \ + listen 80; \ + location / { \ + root /usr/share/nginx/html; \ + index index.html; \ + try_files $uri $uri/ /index.html; \ + } \ +}' > /etc/nginx/conf.d/default.conf + EXPOSE 80 + CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file