diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..329d9c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:17-alpine AS build +RUN apk add --no-cache python3 g++ make +RUN ln -s /usr/bin/python3 /usr/bin/python +WORKDIR /build/ +COPY package* ./ +RUN npm install +COPY . . +RUN npm run build + +FROM node:17-alpine AS prod +WORKDIR /app +COPY --from=build /build . +CMD ["npm", "start"] \ No newline at end of file diff --git a/README.md b/README.md index ebf5cef..b09899b 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ ## 🔩 Setup +New: You can use [Docker](#using-docker) instead. + **Node v16+ is required!** Important: this bot is meant to be used in one server (Discord+Revolt), but can be used in more as long as they share the same admin. @@ -57,6 +59,23 @@ Of course, replace ... with tokens. Note: it's recommended to use something like [pm2](https://pm2.keymetrics.io/) or [nodemon](https://nodemon.io/) to run the bot. Make sure to pass the `--experimental-specifier-resolution=node` flag to node manually, otherwise it will not run (it's included in the default start script). +### Using Docker + +You need Docker and docker-compose installed. + +Follow the steps above to create a `.env` file[^1]. You do not have to run `npm install` and `npm run build`, obviously. Also, make sure your bots have all the required permissions as explained above. + +Before you run docker-compose, use `touch revcord.sqlite` to create the database file and leave it empty. + +Then you should be ready to go. + +``` +docker-compose up -d +``` + +[^1]: Alternatively, you can edit the `docker-compose.yml` file appropriately. Make sure to remove `./.env:/app/.env` below `volumes:` so it won't complain when you don't have a `.env` file. + + ## 🔧 Configuration ### with commands diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7083c64 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: "3.7" + +services: + revcord: + build: + dockerfile: Dockerfile + volumes: + - ./revcord.sqlite:/app/revcord.sqlite:rw + - ./.env:/app/.env + restart: unless-stopped \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e58e1ad..df1e960 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "revcord", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "revcord", - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", "dependencies": { "@discordjs/builders": "^0.12.0", diff --git a/package.json b/package.json index 5806c53..bdd1d6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "revcord", - "version": "1.0.0", + "version": "1.1.0", "description": "A discord-revolt bridge", "type": "module", "scripts": {