Adding docker support
This commit is contained in:
5
.dockerignore
Normal file
5
.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
||||
.git
|
||||
.gitignore
|
||||
node_modules
|
||||
logs
|
||||
dump
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -6,6 +6,10 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Dumps
|
||||
dump
|
||||
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
|
||||
@@ -8,10 +8,12 @@ RUN apk add --no-cache python3 make g++
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json to the working directory
|
||||
COPY package*.json ./
|
||||
COPY ["package.json", "package-lock.json", "./"]
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
RUN npm rebuild bcrypt
|
||||
RUN npm install nodemon -g
|
||||
|
||||
# Copy the rest of the application source code
|
||||
COPY . .
|
||||
@@ -20,7 +22,7 @@ COPY . .
|
||||
EXPOSE 3001
|
||||
|
||||
# Command to run your app
|
||||
CMD ["npm", "start"]
|
||||
CMD ["nodemon"]
|
||||
|
||||
# sudo docker build -t emi-backend .
|
||||
# sudo docker run -d -p 4000:5000 -e PORT=5000 emi-backend
|
||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
version: '3.8'
|
||||
|
||||
networks:
|
||||
emi-network:
|
||||
driver: bridge
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
ports:
|
||||
- '3001:3001'
|
||||
environment:
|
||||
- MONGO_URL=mongodb://mongo:27017/testdb
|
||||
- PORT=3001
|
||||
volumes:
|
||||
- .:/app
|
||||
- '/app/node_modules'
|
||||
depends_on:
|
||||
- mongo
|
||||
command: nodemon
|
||||
networks:
|
||||
- emi-network
|
||||
|
||||
mongo:
|
||||
image: mongo:latest
|
||||
ports:
|
||||
- '27017:27017'
|
||||
networks:
|
||||
- emi-network
|
||||
volumes:
|
||||
- mongodbdata:/data/db
|
||||
- ./dump:/dump
|
||||
#entrypoint: mongodump ${MONGO_URL} && mongorestore --db EMI_SOCIAL dump/EMI_SOCIAL/ && mongod
|
||||
|
||||
volumes:
|
||||
mongodbdata:
|
||||
driver: local # This ensures the volume is created
|
||||
@@ -5,7 +5,10 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node index.js"
|
||||
"start": "node index.js",
|
||||
"docker": "docker compose up -d",
|
||||
"docker_restore": "docker-compose exec mongo mongorestore --db EMI_SOCIAL /dump/EMI_SOCIAL/",
|
||||
"docker_dump": "docker-compose exec mongo mongodump --uri ${MONGO_URL} --out /dump"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
||||
Reference in New Issue
Block a user