docker files updated

This commit is contained in:
Vishnu 2025-03-19 10:29:07 +05:30
parent 124e435504
commit a550635aae
3 changed files with 81 additions and 0 deletions

41
app/Dockerfile Normal file
View File

@ -0,0 +1,41 @@
# Use the argument for node version (defaults to 'lts' if not provided)
ARG NODE_VERSION=lts
# Stage 1: Build Vite React App
FROM node:${NODE_VERSION}-alpine AS development
# Set the Node.js environment to development
ENV NODE_ENV=development
# Set working directory for frontend code
WORKDIR /frontend
# Copy package.json and package-lock.json for npm install
COPY package*.json ./
# Install the latest npm version
RUN npm install -g npm
# Install dependencies (this includes Vite and its plugins)
RUN npm install --legacy-peer-deps
# Copy the rest of the application code
COPY . .
# Run the build command (build the Vite app)
RUN npm run build
# Stage 2: Serve with Nginx
FROM nginx:alpine
# Copy the built Vite files from the build stage into Nginx's default HTML folder
COPY --from=development /frontend/dist /usr/share/nginx/html
# Optionally copy a custom Nginx config (if needed)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80 for Nginx (default HTTP port)
EXPOSE 80
# Start Nginx in the foreground (this is required to keep the container running)
CMD ["nginx", "-g", "daemon off;"]

15
app/nginx.conf Normal file
View File

@ -0,0 +1,15 @@
server {
listen 80;
server_name localhost;
# Point to the Vite build output directory
root /usr/share/nginx/html/dist;
index index.html;
location / {
try_files $uri /index.html;
}
# Redirect 404 errors to index.html (for React Router)
error_page 404 /index.html;
}

25
compose.yaml Normal file
View File

@ -0,0 +1,25 @@
version: "3.8"
services:
dwinzo_beta:
build:
context: ./app
dockerfile: Dockerfile
container_name: dwinzo_beta
stdin_open: true
tty: true
ports:
- "8200:80"
volumes:
# Bind the app directory for development purposes
- ./app:/app
networks:
- dwinzo_beta
networks:
dwinzo_beta:
driver: bridge
volumes:
frontend:
driver: local