charles_c 5 months ago
parent
commit
2e05a53fc2
3 changed files with 56 additions and 7 deletions
  1. 49 0
      docker-compose.lvyin.yml
  2. 4 4
      docker-compose.prod.yml
  3. 3 3
      nginx/default.conf

+ 49 - 0
docker-compose.lvyin.yml

@@ -0,0 +1,49 @@
+services:
+  nextjs:
+    # container_name: match-vote-nextjs-nextjs-1 
+    build:
+      context: .
+      dockerfile: Dockerfile.prod
+      args:
+        - MONGODB_URI=mongodb://mongodb:27017/lvyin_db
+    ports:
+      - "3000:3000"
+    environment:
+      - NODE_ENV=production
+      - MONGODB_URI=mongodb://mongodb:27017/lvyin_db
+    depends_on:
+      - mongodb
+    restart: unless-stopped  # 添加自动重启策略
+    volumes:
+      - uploads_data:/app/public/uploads
+    
+  mongodb:
+    image: mongo
+    volumes:
+      - mongodb_data:/data/db
+    restart: unless-stopped  # 添加自动重启策略
+
+  nginx:
+    # container_name: match-vote-nextjs-nginx-1
+    image: nginx:alpine
+    ports:
+      - "8081:80"
+
+    volumes:
+      - ./nginx:/etc/nginx/conf.d
+      - ./logs/nginx:/var/log/nginx
+      - uploads_data:/app/public/uploads:ro
+      - ./certs:/etc/nginx/certs
+
+    depends_on:
+      - nextjs
+    restart: unless-stopped  # 添加自动重启策略
+
+volumes:
+  mongodb_data:
+  uploads_data:
+
+networks:
+  default:
+    # name: match-vote-network  # 为网络指定一个名称
+

+ 4 - 4
docker-compose.prod.yml

@@ -5,12 +5,12 @@ services:
       context: .
       dockerfile: Dockerfile.prod
       args:
-        - MONGODB_URI=mongodb://mongodb:27017/mydatabase
+        - MONGODB_URI=mongodb://mongodb:27017/lvyin_db
     ports:
       - "3000:3000"
     environment:
       - NODE_ENV=production
-      - MONGODB_URI=mongodb://mongodb:27017/mydatabase
+      - MONGODB_URI=mongodb://mongodb:27017/lvyin_db
     depends_on:
       - mongodb
     restart: unless-stopped  # 添加自动重启策略
@@ -27,8 +27,8 @@ services:
     container_name: match-vote-nextjs-nginx-1
     image: nginx:alpine
     ports:
-      - "8080:80"
-      
+      - "8081:80"
+
     volumes:
       - ./nginx:/etc/nginx/conf.d
       - ./logs/nginx:/var/log/nginx

+ 3 - 3
nginx/default.conf

@@ -1,6 +1,6 @@
 server {
     listen 80;
-    server_name 1919com.com www.1919com.com;
+    server_name lvyin20.tv www.lvyin20.tv;
     
     location / {
         proxy_pass http://match-vote-nextjs-nextjs-1:3000;  # 使用完整的容器名称
@@ -45,6 +45,6 @@ server {
     gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
 
     # 日志格式
-    access_log /var/log/nginx/1919com.com.access.log;
-    error_log /var/log/nginx/1919com.com.error.log;
+    access_log /var/log/nginx/lvyin20.access.log;
+    error_log /var/log/nginx/lvyin20.error.log;
 }