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

build: dockerize app #33

Open
wants to merge 15 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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
smauermann marked this conversation as resolved.
Show resolved Hide resolved
build
.idea
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BLOCK_IO_API_KEY=XXXXXXXXXXXXX
BLOCK_IO_SECRET_PIN=XXXXXXXXXXXXX
SLACK_TOKEN=XXXXXXXXXXXXX
BOT_USER_ID=XXXXXXXXXXXXX
BOT_CHANNEL_MEMBER_ID=XXXXXXXXXXXXX
GENERAL_CHANNEL_ID=XXXXXXXXXXXXX
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
.env
.idea/
yarn-error.log
*.env
build/
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM node:8-alpine

FROM node:12-alpine
WORKDIR /opt/app
COPY . /opt/app

RUN npm i
RUN npm i -g forever
COPY ./ /opt/app/
RUN yarn && yarn build

ENTRYPOINT sh /opt/app/app.sh
FROM node:12-alpine
WORKDIR /opt/app
COPY --from=0 /opt/app/build /opt/app/
RUN yarn --production && yarn cache clean
CMD ["node", "index.js"]
5 changes: 5 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:12-alpine
WORKDIR /opt/app
RUN yarn

CMD ["yarn", "dev"]
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@

`.env` file should look like:

```
```shell
BLOCK_IO_API_KEY=XXXXXXXXX
BLOCK_IO_SECRET_PIN=XXXXXXX
SLACK_TOKEN=xoxb-.....
BOT_USER_ID=-----
GENERAL_CHANNEL_ID=YOUR_GENERAL_CHANNEL
```

`dev.env` should look like this:

```shell
NGROK_ACCOUNT=YOUR_NGROK_ACCOUNT
HOST=doge-cool
PORT=3000
```

### In public / private channels

- `tip <username> <amount>` - gives amount to specified user
Expand All @@ -23,3 +31,12 @@ GENERAL_CHANNEL_ID=YOUR_GENERAL_CHANNEL
- `deposit` - return address
- `balance` - shows balance
- `withdraw <adress> <amount?>` - withdraws to address

## Docker

- develop app in container:
`yarn dev:docker`
- build image:
`yarn build:docker`
- run app in container:
`yarn start:docker`
5 changes: 0 additions & 5 deletions app.sh

This file was deleted.

3 changes: 3 additions & 0 deletions dev.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NGROK_ACCOUNT=XXXXXXXXXXXXX
HOST=XXXXXXXXXXXXX
PORT=3000
19 changes: 19 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"
services:
doge-cool:
build:
context: ./
dockerfile: Dockerfile.dev
volumes:
- ./:/opt/app
ngrok:
image: wernight/ngrok
command: ./start-ngrok.sh
env_file:
- ./.env
- ./dev.env
volumes:
- $HOME/.ngrok2/:/home/ngrok/.ngrok2/
- ./start-ngrok.sh:/start-ngrok.sh
depends_on:
- doge-cool
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"
services:
doge-cool:
image: doge-cool:latest
ports:
- 3000:3000
restart: unless-stopped
logging:
driver: "json-file"
options:
max-file: "10"
max-size: "100m"
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"dev": "nodemon --watch src --ext ts,js --exec 'ts-node' src/index.ts",
"prettier": "prettier --write '**/*.{js,ts,tsx,json,md}'",
"precommit": "pretty-quick --staged",
"start": "sh app.sh"
"build": "yarn tsc && cp src/lib/*.json build/lib/ && cp package.json build/package.json",
"start": "node build/index.js",
"dev:docker": "docker-compose -f docker-compose.dev.yml up",
"build:docker": "docker build -t doge-cool -f Dockerfile .",
"start:docker": "yarn build:docker && docker-compose up"
},
"prettier": {
"singleQuote": true,
Expand Down
3 changes: 3 additions & 0 deletions start-ngrok.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

ngrok http -subdomain="${NGROK_ACCOUNT}" "${HOST}:${PORT}"