Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:14.16.0-alpine3.13

EXPOSE 8008

# Install PM2
RUN npm install -g pm2

# PM2 log rotation
RUN pm2 install pm2-logrotate

# Set working directory to /usr/app
WORKDIR /usr/app

# Set logs directory
VOLUME [ "./logs" ]

# Copy dependency files
COPY package.json .
COPY yarn.lock .

# Install deps
RUN yarn install --ignore-scripts

# Copy project files
COPY pm2.json .
COPY src src/
COPY tsconfig.json .
COPY serverConfig.json .

# Compile
RUN yarn compile

# Run app
CMD [ "pm2-runtime", "pm2.json" ]
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
edge-notifications
# Edge Notifications Server

## Usage

### Install

```
yarn
```

### Configuration

Configure `serverConfig.json.sample` and rename to `serverConfig.json`

#### Running for Development

```
yarn start
```

#### Running Build for Production
```
pm2 start pm2.json
```
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
infoserver:
image: edge-notifications:latest
network_mode: "host"
volumes:
- ./logs:/usr/server/logs
container_name: edge-notifications
64 changes: 32 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"name": "edge-push-notifications",
"version": "1.0.0",
"description": "",
"main": "build/index.js",
"scripts": {
"price:script": "node build/index.js",
"server": "node build/server.js",
"price:script:pm2": "pm2 start build/price-script/index.js --name price-script --log logs/price-script.log --time",
"server:pm2": "pm2 start build/server/index.js --name server --log logs/server.log --time",
"compile": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@pm2/io": "^4.3.5",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"cleaners": "^0.2.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"firebase-admin": "^8.12.1",
"nano": "^8.2.2",
"node-schedule": "^1.3.2"
},
"devDependencies": {
"@types/express": "^4.17.6",
"@types/node": "^14.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.3"
}
}
"name": "edge-push-notifications",
"version": "1.0.0",
"description": "",
"main": "build/index.js",
"scripts": {
"price:script": "node build/index.js",
"server": "node build/server/index.js",
"compile": "tsc",
"pm2": "yarn compile && pm2 start pm2.json && pm2 save",
"start": "yarn compile && yarn server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@pm2/io": "^4.3.5",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"cleaners": "^0.2.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"firebase-admin": "^8.12.1",
"nano": "^8.2.2",
"node-schedule": "^1.3.2"
},
"devDependencies": {
"@types/express": "^4.17.6",
"@types/node": "^14.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.3"
}
}
15 changes: 15 additions & 0 deletions pm2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"apps": [{
"name": "price-script",
"script": "build/price-script/index.js",
"error_file": "logs/price-script/error.log",
"out_file": "logs/price-script/price-script.log"
},
{
"name": "server",
"script": "build/server/index.js",
"error_file": "logs/server/error.log",
"out_file": "logs/server/out.log"
}
]
}