diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..eb2eb41 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,9 @@ +node_modules +dist +build +.DS_Store +.env +.env.local +.env.development.local +.env.test.local +.env.production.local diff --git a/backend/.env.example b/backend/.env.example new file mode 100644 index 0000000..d0d9616 --- /dev/null +++ b/backend/.env.example @@ -0,0 +1,5 @@ +PORT=5000 +MONGO_URI=your-mongodb-atlas-uri +JWT_SECRET=your-secret-key +GEMINI_API_KEY=your-gemini-api-key +KEEP_ALIVE_URL=http://localhost:5000 \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..841527e --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,13 @@ +FROM node:18-alpine + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +EXPOSE 5000 + +CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e64a16d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3.8' + +services: + mongo: + image: mongo + container_name: paisable-mongo + volumes: + - mongo-data:/data/db + networks: + - app-network + ports: + - "27017:27017" + + backend: + build: ./backend + container_name: backend + ports: + - "5000:5000" + environment: + - MONGO_URI=mongodb://mongo:27017/paisable + env_file: + - ./backend/.env + depends_on: + - mongo + networks: + - app-network + + frontend: + build: ./frontend + container_name: frontend + ports: + - "5173:80" + env_file: + - ./frontend/.env + depends_on: + - backend + networks: + - app-network + +networks: + app-network: + driver: bridge + +volumes: + mongo-data: \ No newline at end of file diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..eb2eb41 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,9 @@ +node_modules +dist +build +.DS_Store +.env +.env.local +.env.development.local +.env.test.local +.env.production.local diff --git a/frontend/.env.example b/frontend/.env.example new file mode 100644 index 0000000..6ff1b0c --- /dev/null +++ b/frontend/.env.example @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:5000/api \ No newline at end of file diff --git a/frontend/.gitignore b/frontend/.gitignore index a779547..0516b84 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -24,4 +24,4 @@ dist-ssr *.sln *.sw? .env -.env.* + diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..79f3726 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,18 @@ +# Stage 1 — Build the app +FROM node:18-alpine AS builder + +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# Stage 2 — Serve with Nginx +FROM nginx:alpine + +COPY --from=builder /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/frontend/nginx.conf b/frontend/nginx.conf new file mode 100644 index 0000000..6aed563 --- /dev/null +++ b/frontend/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri /index.html; + } + + # Logs + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; +}