File tree Expand file tree Collapse file tree 4 files changed +32
-8
lines changed
samples/sveltekit-mongodb Expand file tree Collapse file tree 4 files changed +32
-8
lines changed Original file line number Diff line number Diff line change 1+ # Default .dockerignore file for Defang
2+ ** /__pycache__
3+ ** /.direnv
4+ ** /.DS_Store
5+ ** /.envrc
6+ ** /.git
7+ ** /.github
8+ ** /.idea
9+ ** /.next
10+ ** /.vscode
11+ ** /compose. * .yaml
12+ ** /compose. * .yml
13+ ** /compose.yaml
14+ ** /compose.yml
15+ ** /docker-compose. * .yaml
16+ ** /docker-compose. * .yml
17+ ** /docker-compose.yaml
18+ ** /docker-compose.yml
19+ ** /node_modules
20+ ** /Thumbs.db
21+ Dockerfile
22+ * .Dockerfile
23+ # Ignore our own binary, but only in the root to avoid ignoring subfolders
24+ defang
25+ defang.exe
26+ # Ignore our project-level state
27+ .defang
Original file line number Diff line number Diff line change @@ -18,10 +18,6 @@ RUN npm install
1818# Copy the rest of the application code
1919COPY . .
2020
21- # Set environment variable for MongoDB URI
22- ARG MONGODB_URI
23- ENV MONGODB_URI=$MONGODB_URI
24-
2521# Build the SvelteKit application
2622RUN npm run build
2723
Original file line number Diff line number Diff line change 11import { MongoClient } from 'mongodb' ;
22
3- const uri = process . env . MONGODB_URI || 'mongodb://localhost:27017/musicdb' ;
3+ const uri = process . env . MONGO_URL || 'mongodb://localhost:27017/musicdb' ;
4+ console . log ( `Connecting to MongoDB at URL = ${ uri } ` ) ;
45const client = new MongoClient ( uri ) ;
56
67let cachedClient = null ;
Original file line number Diff line number Diff line change @@ -4,13 +4,11 @@ services:
44 build :
55 context : ./app
66 dockerfile : Dockerfile
7- args :
8- MONGODB_URI : " mongodb://mongo:27017/musicdb"
97 environment :
108 NODE_ENV : production
119 HOST : " 0.0.0.0"
1210 PORT : 3000
13- MONGODB_URI : " mongodb://mongo:27017/musicdb"
11+ MONGO_URL : " mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@ mongo:27017/musicdb?retryWrites=false&authMechanism=SCRAM-SHA-1&authSource=admin "
1412 ports :
1513 - " 3000:3000"
1614 depends_on :
@@ -31,6 +29,8 @@ services:
3129 volumes :
3230 - mongo-data:/data/db
3331 environment :
32+ MONGO_INITDB_ROOT_USERNAME :
33+ MONGO_INITDB_ROOT_PASSWORD :
3434 MONGO_INITDB_DATABASE : musicdb
3535 # deploy:
3636 # resources:
You can’t perform that action at this time.
0 commit comments