diff --git a/Dockerfile b/Dockerfile index 3fc1bde..f0e637a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,19 @@ -# Use Node.js 20 Alpine as base image for smaller size -FROM node:20-alpine +FROM node:20-alpine AS builder -# Set working directory WORKDIR /app -# Install dependencies for node-gyp and other native modules -RUN apk add --no-cache python3 make g++ - -# Copy package files COPY package.json yarn.lock ./ +RUN corepack enable && yarn install --frozen-lockfile -# Install dependencies -RUN yarn install --frozen-lockfile - -# Copy source code COPY . . +RUN yarn build -# Expose Vite dev server port -EXPOSE 5173 +FROM nginx:1.27-alpine -# Set environment variables for development -ENV NODE_ENV=development -ENV CHOKIDAR_USEPOLLING=true -ENV WATCHPACK_POLLING=true +RUN rm -rf /usr/share/nginx/html/* +COPY --from=builder /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] -# Start the development server -CMD ["yarn", "dev", "--host", "0.0.0.0"] \ No newline at end of file diff --git a/Dockerfile.prod b/Dockerfile.prod deleted file mode 100644 index ff2e332..0000000 --- a/Dockerfile.prod +++ /dev/null @@ -1,25 +0,0 @@ -# Stage 1: Build the Vite application -FROM node:20-alpine AS build - -WORKDIR /app - -# Install dependencies -COPY package.json yarn.lock ./ -RUN yarn install --frozen-lockfile - -# Copy source code and build -COPY . . -RUN yarn build - -# Stage 2: Serve with nginx -FROM nginx:1.27-alpine - -# Copy nginx configuration tuned for a single-page application -COPY nginx.conf /etc/nginx/nginx.conf - -# Copy built assets -COPY --from=build /app/dist /usr/share/nginx/html - -EXPOSE 80 - -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml deleted file mode 100644 index 426ef94..0000000 --- a/docker-compose.prod.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: '3.8' - -services: - dashboard-app-prod: - build: - context: . - dockerfile: Dockerfile.prod - ports: - - '3010:80' - environment: - - NODE_ENV=production - env_file: - - .env.prod - restart: unless-stopped - networks: - - dashboard-network - healthcheck: - test: ['CMD', 'curl', '-f', 'http://localhost/'] - interval: 30s - timeout: 10s - retries: 3 - start_period: 40s - -networks: - dashboard-network: - driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b518b32..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: '3.8' - -services: - dashboard-app-dev: - build: - context: . - dockerfile: Dockerfile - ports: - - '3011:3000' - volumes: - # Mount source code for hot reloading - - .:/app - # Exclude node_modules to use container's version - - /app/node_modules - environment: - - NODE_ENV=development - - CHOKIDAR_USEPOLLING=true - - WATCHPACK_POLLING=true - - REACT_APP_API_URL=${REACT_APP_API_URL:-https://amazon.fascano.com} - env_file: - - .env.develop - stdin_open: true - tty: true - networks: - - dashboard-network - -networks: - dashboard-network: - driver: bridge