Browse Source

MONGODB_URI

alexcdev1 6 months ago
parent
commit
dc36ccd8ac
2 changed files with 7 additions and 1 deletions
  1. 2 1
      .env.local
  2. 5 0
      Dockerfile.prod

+ 2 - 1
.env.local

@@ -1,4 +1,5 @@
 # MONGODB_URI=mongodb+srv://admin:password123@cluster0.mongodb.net/mydatabase?retryWrites=true&w=majority
 # MONGODB_URI=mongodb://localhost:27017/mydatabase
 # MONGODB_URI=mongodb+srv://alexcdev:MM2wUnaykoiK904j@cluster0.snuq8.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
-# MONGODB_DB_NAME=mydatabase
+# MONGODB_DB_NAME=mydatabase
+MONGODB_URI=mongodb://mongodb:27017/mydatabase

+ 5 - 0
Dockerfile.prod

@@ -9,6 +9,11 @@ RUN yarn install --frozen-lockfile
 # Rebuild the source code only when needed
 FROM node:alpine AS builder
 WORKDIR /app
+
+# 添加这行
+ARG MONGODB_URI
+ENV MONGODB_URI=$MONGODB_URI
+
 COPY . .
 COPY --from=deps /app/node_modules ./node_modules
 RUN yarn build && yarn install --production --ignore-scripts --prefer-offline