docker timeee

This commit is contained in:
Lea 2023-06-27 14:34:19 +02:00
parent f1f0278b31
commit c91831bf73
Signed by: Lea
GPG key ID: 1BAFFE8347019C42
7 changed files with 96 additions and 4 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
node_modules
.private

View file

@ -1,5 +1,10 @@
TOKEN=
MONGODB_URI=mongodb://
# Not required for docker deployment, use MONGODB-{USERNAME,PASSWORD} instead
# MONGODB_URI=mongodb://
MONGODB_USERNAME=automod
MONGODB_PASSWORD=
MOBGODB_DATABASE=automod
REDIS_URI=redis://
PREFIX=/

47
bot/Dockerfile Normal file
View file

@ -0,0 +1,47 @@
FROM node:19 as build
WORKDIR /build
COPY bot/package.json bot/tsconfig.json ./bot/
COPY lib/package.json lib/tsconfig.json ./lib/
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
COPY external ./external
# Install pnpm
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
RUN pnpm install --frozen-lockfile
# Build revolt.js
WORKDIR /build/external/revolt.js
RUN pnpm run build
# Build lib
WORKDIR /build/lib
COPY lib/src ./src
RUN pnpm run build
# Build bot
WORKDIR /build/bot
COPY bot/src ./src
RUN pnpm run build
FROM node:19 as run
WORKDIR /app
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
COPY --from=build /root/.local/share/pnpm/store /root/.local/share/pnpm/store
COPY --from=build /build/node_modules ./node_modules
COPY --from=build /build/bot/package.json ./bot/
COPY --from=build /build/bot/dist ./bot/dist
COPY --from=build /build/lib/package.json ./lib/
COPY --from=build /build/lib/dist ./lib/dist
COPY --from=build /build/external/translations ./external/translations
COPY --from=build /build/external/revolt.js/package.json ./external/revolt.js/
COPY --from=build /build/external/revolt.js/lib ./external/revolt.js/lib
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
RUN pnpm install --frozen-lockfile
WORKDIR /app/bot
CMD [ "pnpm", "run", "start" ]

View file

@ -5,7 +5,9 @@
"type": "module",
"exports": "./dist/index",
"scripts": {
"dev": "tsc-watch --onSuccess \"node dist\""
"dev": "tsc-watch --onSuccess \"node dist\"",
"build": "rm -rf dist && tsc",
"start": "node dist/index.js"
},
"keywords": [],
"author": "",

31
docker-compose.yml Normal file
View file

@ -0,0 +1,31 @@
version: '3.1'
services:
bot:
build:
context: .
dockerfile: bot/Dockerfile
restart: unless-stopped
environment:
- MONGODB_URI=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@db/admin
- REDIS_URI=redis://redis:6379
- MONGODB_DATABASE=${MONGODB_DATABASE:-automod}
- PREFIX=${PREFIX:-/}
- TOKEN
depends_on:
- db
- redis
db:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: $MONGODB_USERNAME
MONGO_INITDB_ROOT_PASSWORD: $MONGODB_PASSWORD
ports:
- 127.0.0.1:27017:27017
volumes:
- ./.private/db:/data/db:rw
redis:
image: eqalpha/keydb
restart: always

View file

@ -6,7 +6,8 @@
"module": "dist/index.js",
"main": "dist/index.js",
"scripts": {
"dev": "tsc-watch --onSuccess \"node dist\""
"dev": "tsc-watch --onSuccess \"node dist\"",
"build": "rm -rf dist && tsc"
},
"keywords": [],
"author": "",
@ -22,6 +23,7 @@
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"eslint": "^8.42.0",
"tsc-watch": "^6.0.0"
"tsc-watch": "^6.0.0",
"typescript": "^5.0.3"
}
}

View file

@ -164,6 +164,9 @@ importers:
tsc-watch:
specifier: ^6.0.0
version: 6.0.4(typescript@5.1.3)
typescript:
specifier: ^5.0.3
version: 5.1.3
packages: