Skip to content

Commit

Permalink
Merge pull request #48 from ld-web/docker
Browse files Browse the repository at this point in the history
🐳 Docker support
  • Loading branch information
keikaavousi authored Mar 9, 2022
2 parents 707394f + f75abda commit 0125349
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env
.git
.vscode
.*ignore
docker-compose*.yml
node_modules
*.md
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PORT=8765

DB_HOST=localhost
DB_HOST=db
DB_USERNAME=root
DB_PASSWORD=example
DB_NAME=fake_store
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
package-lock.json
.vscode
app.js
Procfile
Procfile
mongo_data
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:17

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE $PORT

CMD [ "node", "server.js" ]
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.1'

services:
app:
build: .
env_file:
- .env
ports:
- "${PORT}:${PORT}"
depends_on:
- db
db:
image: mongo
restart: always
volumes:
- ./mongo_data:/data/db
env_file:
- .env
environment:
MONGO_INITDB_ROOT_USERNAME: ${DB_USERNAME?MongoDB username}
MONGO_INITDB_ROOT_PASSWORD: ${DB_PASSWORD?MongoDB password}

0 comments on commit 0125349

Please sign in to comment.