docker
This commit is contained in:
parent
84af08450e
commit
47dcaabc5c
5 changed files with 37 additions and 7 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
npm-debug.log
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
|
@ -0,0 +1,13 @@
|
|||
FROM node:14-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm install --production
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "dist/index.js"]
|
|
@ -1,5 +1,20 @@
|
|||
version: '3'
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
- ./src:/app/src
|
||||
- ./dist:/app/dist
|
||||
environment:
|
||||
- DB_DATABASE=your-database-name
|
||||
- DB_USERNAME=your-username
|
||||
- DB_PASSWORD=your-password
|
||||
depends_on:
|
||||
- mongodb
|
||||
mongodb:
|
||||
image: arm64v8/mongo:4.0
|
||||
restart: always
|
||||
|
@ -9,11 +24,11 @@ services:
|
|||
- structshare_vol:/data/db
|
||||
- ./init-scripts/init.js:/docker-entrypoint-initdb.d/mongo-init.js
|
||||
environment:
|
||||
- MONGO_INITDB_DATABASE=${DB_DATABASE}
|
||||
- MONGO_INITDB_ROOT_USERNAME=${DB_USERNAME}
|
||||
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
|
||||
- MONGO_INITDB_DATABASE=your-database-name
|
||||
- MONGO_INITDB_ROOT_USERNAME=your-username
|
||||
- MONGO_INITDB_ROOT_PASSWORD=your-password
|
||||
platform: linux/arm64/v8
|
||||
expose:
|
||||
- 27017
|
||||
volumes:
|
||||
structshare_vol:
|
||||
structshare_vol:
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "nodemon dist/index.js",
|
||||
"start": "node dist/index.js"
|
||||
"start": "node dist/index.js",
|
||||
"build": "tsc -p ."
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
|
|
@ -9,12 +9,11 @@ import cartRouter from './routes/cart';
|
|||
const env = require('dotenv').config().parsed;
|
||||
|
||||
const app = express();
|
||||
const PORT = 3000;
|
||||
const PORT = env.PORT || 3000;
|
||||
|
||||
app.use(express.json());
|
||||
app.use(cookieParser())
|
||||
|
||||
|
||||
// Connect to MongoDB using Mongoose
|
||||
mongoose.connect(env.DATABASE_URL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue