Skip to content

Commit

Permalink
Merge pull request #564 from aternosorg/docker-image
Browse files Browse the repository at this point in the history
Build a docker Image for all releases and commits to master.
  • Loading branch information
JulianVennen authored Mar 23, 2023
2 parents ad29000 + eba088e commit cbc4d4d
Show file tree
Hide file tree
Showing 10 changed files with 5,967 additions and 32 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git
.github
.idea
.eslintrc.json
.gitignore
config.json
LICENSE
*.md
42 changes: 42 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and push Docker image

on:
push:
branches:
- master
release:
types:
- published

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/config.json
/node_modules/
.idea
package-lock.json
11 changes: 4 additions & 7 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Database hostname or IP
| string | `database.host` | `MODBOT_DATABASE_HOST` |

### User
Database username
Database username (Default: `modbot`)

| type | config file | environment |
|--------|-----------------|------------------------|
Expand All @@ -41,14 +41,14 @@ Database password
| string | `database.password` | `MODBOT_DATABASE_PASSWORD` |

### Database
Database name
Database name (Default: `modbot`)

| type | config file | environment |
|--------|---------------------|----------------------------|
| string | `database.database` | `MODBOT_DATABASE_DATABASE` |

### Port
Database port
Database port (Default: `3306`)

| type | config file | environment |
|--------|-----------------|------------------------|
Expand Down Expand Up @@ -252,10 +252,7 @@ For details on the configuration options see above.
"authToken": "AUTH TOKEN",
"database": {
"host": "localhost",
"user": "modbot",
"password": "password",
"database": "modbot",
"port": 3306
"password": "password"
}
}
```
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:18-alpine

ARG COMMIT_HASH

# Set up files
WORKDIR /app
COPY . .

# Install dependencies
ENV NODE_ENV=production
RUN npm ci

# Environment
ENV MODBOT_COMMIT_HASH=$COMMIT_HASH
ENV MODBOT_USE_ENV=1
CMD ["npm", "start"]
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,28 @@ If you think you found a bug in ModBot then please create an [issue](https://git
For security issues please refer to the [SECURITY.md](./SECURITY.md).

### Self Hosting
Requirements: [Node.js](https://nodejs.org/en/download/) (v16.9.0+), a [MySQL](https://dev.mysql.com/downloads/mysql/) database
1. Download the code and run `npm install`
2. Create a [Discord application](https://discord.com/developers/applications/).
You also have to enable the SERVER MEMBERS intent.
If you want to host the bot yourself you can use our pre-built docker image or install it directly.
In both cases you will need a [MySQL](https://dev.mysql.com/downloads/mysql/) database and a
[Discord application](https://discord.com/developers/applications/):

1. Create a [Discord application](https://discord.com/developers/applications/) and enable the SERVER MEMBERS intent.
The bot needs this to reassign the muted role when a muted user joins your server
3. Add a bot to the application and copy the auth token
4. (optional) Create an API key in the [Google Cloud Console](https://console.cloud.google.com/) for the YouTube Data API v3
5. Configure the bot (see [CONFIGURATION.md](./CONFIGURATION.md))
6. Start the index.js file
7. To invite the bot to your server replace `ID` with the client ID of your application
2. Add a bot to the application and copy the auth token
3. Configure the bot (see [CONFIGURATION.md](./CONFIGURATION.md))
4. To invite the bot to your server replace `ID` with the client ID of your application
https://discord.com/oauth2/authorize?client_id=ID&scope=bot%20applications.commands&permissions=1099780074518 and open the link
5. Follow the instructions for the installation method you want to use

#### Docker
Requirements: [Docker](https://docs.docker.com/get-docker/)
```bash
docker run -e MODBOT_AUTH_TOKEN="<discord-auth-token>" -e MODBOT_DATABASE_HOST="<database-host>" -e MODBOT_DATABASE_PASSWORD="<database-password>" ghcr.io/aternosorg/modbot
```

#### Direct Installation
Requirements: [Node.js](https://nodejs.org/en/download/) (v16.9.0+), a [MySQL](https://dev.mysql.com/downloads/mysql/) database
1. Download the code and run `npm ci`
2. Run `npm start` to start the bot

### Contributing
If you want to contribute you need to [fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo)
Expand Down
Loading

0 comments on commit cbc4d4d

Please sign in to comment.