From 6785b2db7b84c0692c7d4abfb97d135228d95b34 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 5 Jan 2022 14:22:25 +0200 Subject: [PATCH] docker related stuff --- .dockerignore | 1 + .github/workflows/docker-image.yml | 29 +++++++++++++++++++++++++++++ Dockerfile | 3 ++- README.md | 16 +++++++++++++++- index.js | 7 +++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docker-image.yml diff --git a/.dockerignore b/.dockerignore index b6f1c45..715c132 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,7 @@ old.eslintrc.js node_modules +modmail_cache canned_replies.json persistent_cache.json config.js diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..0153566 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index abbde5e..4dbbbf5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,5 @@ WORKDIR /modmail COPY . . RUN yarn install --production VOLUME [ "/modmail/modmail_cache" ] -CMD ["node", "index.js"] \ No newline at end of file +ENTRYPOINT [ "/bin/ash" ] +# CMD ["node", "index.js"] \ No newline at end of file diff --git a/README.md b/README.md index 951eb12..6c0d040 100644 --- a/README.md +++ b/README.md @@ -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. 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 > 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. > 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. diff --git a/index.js b/index.js index b866617..a7f3a50 100644 --- a/index.js +++ b/index.js @@ -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 { Client } = require('./structure');