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'
|
version: '3'
|
||||||
services:
|
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:
|
mongodb:
|
||||||
image: arm64v8/mongo:4.0
|
image: arm64v8/mongo:4.0
|
||||||
restart: always
|
restart: always
|
||||||
|
@ -9,9 +24,9 @@ services:
|
||||||
- structshare_vol:/data/db
|
- structshare_vol:/data/db
|
||||||
- ./init-scripts/init.js:/docker-entrypoint-initdb.d/mongo-init.js
|
- ./init-scripts/init.js:/docker-entrypoint-initdb.d/mongo-init.js
|
||||||
environment:
|
environment:
|
||||||
- MONGO_INITDB_DATABASE=${DB_DATABASE}
|
- MONGO_INITDB_DATABASE=your-database-name
|
||||||
- MONGO_INITDB_ROOT_USERNAME=${DB_USERNAME}
|
- MONGO_INITDB_ROOT_USERNAME=your-username
|
||||||
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASSWORD}
|
- MONGO_INITDB_ROOT_PASSWORD=your-password
|
||||||
platform: linux/arm64/v8
|
platform: linux/arm64/v8
|
||||||
expose:
|
expose:
|
||||||
- 27017
|
- 27017
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nodemon dist/index.js",
|
"dev": "nodemon dist/index.js",
|
||||||
"start": "node dist/index.js"
|
"start": "node dist/index.js",
|
||||||
|
"build": "tsc -p ."
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|
|
@ -9,12 +9,11 @@ import cartRouter from './routes/cart';
|
||||||
const env = require('dotenv').config().parsed;
|
const env = require('dotenv').config().parsed;
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 3000;
|
const PORT = env.PORT || 3000;
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(cookieParser())
|
app.use(cookieParser())
|
||||||
|
|
||||||
|
|
||||||
// Connect to MongoDB using Mongoose
|
// Connect to MongoDB using Mongoose
|
||||||
mongoose.connect(env.DATABASE_URL);
|
mongoose.connect(env.DATABASE_URL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue