Added frontend in the docker compose

This commit is contained in:
2025-09-26 22:04:31 +02:00
parent b0289d865c
commit cdbc93d4aa
4 changed files with 75 additions and 1 deletions

View File

@@ -68,6 +68,19 @@ services:
- mydocmanager-network
command: celery -A tasks.main worker --loglevel=info
# Frontend - React application with Vite
frontend:
build:
context: ./src/frontend
dockerfile: Dockerfile
container_name: mydocmanager-frontend
ports:
- "5173:5173"
volumes:
- ./src/frontend:/app
- /app/node_modules # Anonymous volume to prevent node_modules override
networks:
- mydocmanager-network
volumes:
mongodb-data:

View File

@@ -102,7 +102,7 @@ app = FastAPI(
# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"], # React frontend
allow_origins=["http://localhost:5173"], # React frontend
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],

View File

@@ -0,0 +1,41 @@
# Dependencies
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Build outputs
dist
build
# Environment files
.env.local
.env.development.local
.env.test.local
.env.production.local
# IDE files
.vscode
.idea
*.swp
*.swo
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Git
.git
.gitignore
# Docker
Dockerfile
.dockerignore
# Logs
*.log

20
src/frontend/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
# Use Node.js 20 Alpine for lightweight container
FROM node:20-alpine
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json (if available)
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy source code
COPY . .
# Expose Vite default port
EXPOSE 5173
# Start development server with host 0.0.0.0 to accept external connections
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"]