docker related stuff

This commit is contained in:
Erik 2022-01-05 14:22:25 +02:00
parent 26216e23d1
commit 6785b2db7b
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589
5 changed files with 54 additions and 2 deletions

View File

@ -4,6 +4,7 @@ old.eslintrc.js
node_modules node_modules
modmail_cache
canned_replies.json canned_replies.json
persistent_cache.json persistent_cache.json
config.js config.js

29
.github/workflows/docker-image.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Docker Image CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/modmail:latest

View File

@ -3,4 +3,5 @@ WORKDIR /modmail
COPY . . COPY . .
RUN yarn install --production RUN yarn install --production
VOLUME [ "/modmail/modmail_cache" ] VOLUME [ "/modmail/modmail_cache" ]
CMD ["node", "index.js"] ENTRYPOINT [ "/bin/ash" ]
# CMD ["node", "index.js"]

View File

@ -6,11 +6,25 @@ Uses json for storage. If this is a problem, feel free to start a branch and wri
Shouldn't require much setup, fill in the relevant fields in config.js, should be well commented. Shouldn't require much setup, fill in the relevant fields in config.js, should be well commented.
I've tried refactoring some of the original code that I wrote initially in haste, but a lot of it's still very questionable and in need of rewriting/refactoring. I've tried refactoring some of the original code that I wrote initially in haste, but a lot of it's still very questionable and in need of rewriting/refactoring.
Contributions welcome. Contributions welcome.
## Docker image
**Highly recommend making a named volume for the storage**
> Create a named volume `docker volume create ModmailStorage`
Make sure to have a config.js ready to go, see the example file for a template
> Start the container
```
docker run -d --name modmail \
-v /path/to/config.js:/modmail/config.js \
-v ModmailStorage:/modmail/modmail_cache \
navydotgif/modmail:latest
```
## How to use ## How to use
> Install [Node.js](https://nodejs.org/en/download/), at least v12, though I'd recommend at least 14 due to Discord.js requiring it in v13. > Install [Node.js](https://nodejs.org/en/download/), at least v12, though I'd recommend at least 14 due to Discord.js requiring it in v13.
> Run `git clone https://github.com/GalacticBot/modmail.git`
> Run `yarn install`, alternatively `npm install` if you don't have yarn for some reason. > Run `yarn install`, alternatively `npm install` if you don't have yarn for some reason.
> Rename `config.example.js` to `config.js`, open it and fill in the relevant values. The comments should explain what they are for. If something is unclear open an issue and I'll attempt to make it more clear. > Rename `config.example.js` to `config.js`, open it and fill in the relevant values. The comments should explain what they are for. If something is unclear open an issue and I'll attempt to make it more clear.

View File

@ -1,3 +1,10 @@
if (!require('fs').existsSync('./config')) {
// eslint-disable-next-line no-console
console.error(`Missing config file.`);
// eslint-disable-next-line no-process-exit
process.exit(0);
}
const Options = require('./config'); const Options = require('./config');
const { Client } = require('./structure'); const { Client } = require('./structure');