Skip to content

Commit

Permalink
Merge pull request #61 from JamesLongman/#54
Browse files Browse the repository at this point in the history
#54 Docker update
  • Loading branch information
JamesLongman committed Nov 5, 2018
2 parents 8788836 + a0348cb commit 334b6c9
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 161 deletions.
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright © 2018 DIG Development team. All rights reserved.

# Ignore local npm modules and logs
node_modules
npm-debug.log

# Ignore local configuration
config/local.json

# Ignore all md files
*.md

# Ignore all hidden files(git, travis, docker, etc)
.*

# Ignore all docker files
Dockerfile
docker-compose*.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
npm-debug.log
vagrant/.vagrant
vagrant/ubuntu*
docker/db
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ services:

before_script:
- docker-compose -f docker-compose-test-ci.yml up --build -d
- docker-compose exec digbot npm install --only=dev

script:
- docker-compose exec node ./app/test.sh
- docker-compose exec digbot npm run mocha

after_script:
- docker-compose down
Expand Down
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright © 2018 DIG Development team. All rights reserved.

FROM node:7.6

# Sets default values for env vars for the image
ENV NODE_ENV=development \
DIGBOT_PORT=1337

# Create and cd into the directory where the bot will live
WORKDIR /usr/src/digbot

# Copy package & package-lock files before other files
COPY package*.json ./

# Install dependencies(dev-dependecies are not installed)
RUN npm install --only=prod

# Copies the project into the container
COPY . .

# Expose port 1337
EXPOSE 1337

# Run the bot
CMD ["npm", "start"]
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ DIGBot is capable of reacting when events are scheduled to remind people of thei
Some channels the community would prefer to always have a free version of. This is the case for channels such as dedicated voice channels for certain games, for example if a member joins a voice channel for a game such as planetside DIGBot will react by creating a second voice channel for that game so there is still a free channel. Every-time a modular channel become populated or empty, DIGBot will respond by creating or deleting a channel as needed


## Usage

### Requirements

The bot uses docker 1.13.0+. Installation instructions can be found here: https://docs.docker.com/install/

### From Docker Hub

It is possible to pull the latest image from Docker Hub using `docker pull dignityofwar/digbot`. Check the readme file in config to configure the bot correctly.

### From the repository

To run the bot locally use `npm run docker:start`, to check the logs use `npm run docker:logs`, and to stop the container and remove it use `npm run docker:stop`. To quickly run the container and view it's logs use `npm run up`, and for taking it down use `npm run down`. The local.json config file will be automatically linked to the container. It is possible to run the bot without docker using `npm start`, but this is not recommended.

To run the tests you use `npm test` (this will also link the local.json config file). It is possible to run it without docker using `npm run mocha`, but this is not recommended.

## Development

### Contributing
Expand Down
9 changes: 3 additions & 6 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

version: '3.0'
services:
node:
build:
context: .
dockerfile: docker/Dockerfile
digbot:
image: "dignityofwar/digbot:latest"
ports:
- "1337:1337"
entrypoint: /app/run.sh
tty: true
restart: always
environment:
- NODE_ENV=production
- NODE_ENV=production
10 changes: 3 additions & 7 deletions docker-compose-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

version: '3.0'
services:
node:
build:
context: .
dockerfile: docker/Dockerfile
digbot:
image: "dignityofwar/digbot:staging"
ports:
- "1337:1337"
entrypoint: /app/run.sh
tty: true
restart: always
environment:
- NODE_ENV=staging
- DIGBOT_PORT=1338
- NODE_ENV=staging
15 changes: 7 additions & 8 deletions docker-compose-test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

version: '3.0'
services:
node:
build:
context: .
dockerfile: docker/Dockerfile-test
digbot:
build: .
ports:
- "1337:1337"
entrypoint: "" # Overwrites CMD so that the bot will not start
tty: true
environment:
- NODE_ENV=testing
- DISCORD_API_TOKEN
- SUBBOTS_CONFIG
- SUBBOTS_LIMIT
- NODE_ENV=testing
- DISCORD_API_TOKEN
- SUBBOTS_CONFIG
- SUBBOTS_LIMIT
13 changes: 7 additions & 6 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

version: '3.0'
services:
node:
build:
context: .
dockerfile: docker/Dockerfile-test
digbot:
build: .
ports:
- "1337:1337"
entrypoint: /app/test.sh
entrypoint: ""
volumes:
# Links the local.json config to the container for local testing
- ./config/local.json:/usr/src/digbot/config/local.json
tty: true
environment:
- NODE_ENV=testing
- NODE_ENV=testing
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

version: '3.0'
services:
node:
build:
context: .
dockerfile: docker/Dockerfile
digbot:
build: .
volumes:
# Links the local.json config to the container for local development
- ./config/local.json:/usr/src/digbot/config/local.json
ports:
- "1337:1337"
entrypoint: /app/run.sh
tty: true
8 changes: 0 additions & 8 deletions docker/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions docker/Dockerfile-test

This file was deleted.

78 changes: 0 additions & 78 deletions docker/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions docker/run.sh

This file was deleted.

14 changes: 0 additions & 14 deletions docker/test.sh

This file was deleted.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
"description": "- Nodejs 7.x\r - npm: discord.js",
"main": "index.js",
"scripts": {
"test": "mocha"
"start": "node src/bot.js",
"mocha": "mocha",
"test": "docker-compose -f docker-compose-test.yml up --build -d && docker-compose exec digbot npm install --only=dev && docker-compose exec digbot npm run mocha && docker-compose down",
"docker:start": "docker-compose up --build -d",
"docker:logs": "docker-compose logs -f digbot",
"docker:stop": "docker-compose down",
"up": "npm run docker:start && npm run docker:logs",
"down": "npm run docker:stop"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion version.txt

This file was deleted.

0 comments on commit 334b6c9

Please sign in to comment.