Skip to content

Commit

Permalink
chore: added redis container
Browse files Browse the repository at this point in the history
  • Loading branch information
filename24 committed Jul 27, 2023
1 parent e0a8a54 commit 9d15ac9
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 70 deletions.
8 changes: 4 additions & 4 deletions .yarn/patches/dokdo-npm-1.0.1-3b43b27044.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff --git a/package.json b/package.json
index c4767972038320b664c412357caa222f3c9f8a9d..c0c3f11b655dd9fa8f1271d98d9ba21d190fbf12 100644
index c4767972038320b664c412357caa222f3c9f8a9d..ae9bbf844bee3af6a36df51bb13df2efce39947c 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
@@ -1,6 +1,7 @@
{
"name": "dokdo",
"version": "1.0.1",
"description": "Dokdo. Easy Discord bot debuging tool.",
+ "type": "module",
"description": "Dokdo. Easy Discord bot debuging tool.",
"scripts": {
"build": "tsup",
"dev": "yarn test:bot",
43 changes: 27 additions & 16 deletions apps/bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
FROM node:18 AS Builder
FROM node:18-alpine AS builder

# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=bot --docker

COPY package.json ./
COPY turbo.json ./
COPY yarn.lock ./
COPY .yarnrc.yml ./
COPY tsup.config.ts ./
COPY .yarn/ ./.yarn/
FROM node:18-alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app

COPY apps/bot/package.json ./apps/bot/package.json
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
COPY --from=builder /app/.yarnrc.yml ./.yarnrc.yml
COPY --from=builder /app/.yarn/ ./.yarn/

COPY packages/ ./packages/
RUN yarn install

RUN yarn install --inline-builds
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
COPY tsconfig.json tsconfig.json
COPY tsup.config.ts tsup.config.ts

COPY apps/bot ./apps/bot/
RUN yarn turbo run build --filter=bot...

RUN yarn build --filter=bot
FROM node:18-alpine AS runner

FROM node:18-alpine AS Server
RUN apk add --no-cache bash git openssh python3 build-base libc6-compat

WORKDIR /app

COPY --from=Builder /app/apps/bot/dist/ ./dist
COPY --from=Builder /app/apps/bot/package.json .
COPY --from=installer /app .

CMD ["node", "./dist/index.js"]
CMD yarn workspace bot start:node
1 change: 1 addition & 0 deletions apps/bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"eslint-config-tempo": "workspace:^",
"nodemon": "^3.0.1",
"tsc-alias": "^1.8.7",
"tsconfig": "workspace:^",
"tsx": "^3.12.7",
"typescript": "^5.1.6"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/bot/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"preserveConstEnums": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"moduleResolution": "Node",
"moduleResolution": "NodeNext",
"skipLibCheck": true,
"outDir": "./dist",
"baseUrl": "src",
Expand Down
22 changes: 17 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
version: '3.8'

networks:
tempo:

volumes:
database_data:
cache_data:

services:
app:
container_name: tempo-bot
environment:
- SHELL=bash
- NODE_ENV=production
- DATABASE_URL=postgresql://postgres:helloworld@database/tempo
- REDIS_URL=redis://cache:6379
env_file:
- .env
networks:
- tempo
build:
context: .
dockerfile: apps/bot/Dockerfile

database:
image: timescale/timescaledb:latest-pg13
container_name: tempo-db
Expand All @@ -25,8 +34,11 @@ services:
- database_data:/var/lib/postgresql/data
restart: always

networks:
tempo:

volumes:
database_data:
cache:
image: 'docker.dragonflydb.io/dragonflydb/dragonfly'
ulimits:
memlock: -1
volumes:
- cache_data:/data
networks:
- tempo
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@commitlint/cli": "^17.6.7",
"@commitlint/config-angular": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@turbo/gen": "^1.10.11",
"@turbo/gen": "^1.10.12",
"@types/eslint": "^8",
"@types/node": "^18.17.0",
"eslint": "^8.45.0",
Expand All @@ -28,12 +28,12 @@
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"tsup": "^7.1.0",
"turbo": "^1.10.11",
"turbo": "^1.10.12",
"typescript": "^5.1.6"
},
"resolutions": {
"dokdo@1.0.1": "patch:dokdo@npm:1.0.1#.yarn/patches/dokdo-npm-1.0.1-3b43b27044.patch",
"eslint-config-neon@^0.1.47": "patch:eslint-config-neon@npm%3A0.1.47#./.yarn/patches/eslint-config-neon-npm-0.1.47-6e2f4c3d60.patch"
"eslint-config-neon@^0.1.47": "patch:eslint-config-neon@npm%3A0.1.47#./.yarn/patches/eslint-config-neon-npm-0.1.47-6e2f4c3d60.patch",
"dokdo@^1.0.1": "patch:dokdo@npm%3A1.0.1#./.yarn/patches/dokdo-npm-1.0.1-3b43b27044.patch"
},
"workspaces": [
"apps/*",
Expand Down
1 change: 1 addition & 0 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"eslint-config-tempo": "workspace:^",
"ioredis": "^5.3.2",
"prisma": "^5.0.0",
"tsconfig": "workspace:^",
"tsup": "^7.1.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/database/src/structures/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class DatabaseClient extends PrismaClient {
this.logger = new Logger('Database', { logPath: options.loggerPath })

// @ts-ignore
this.redis = new Redis(options.redis ?? process.env.REDIS_URL)
this.redis = new Redis(options.redis ?? process.env.REDIS_URL ? { hostname: 'cache' } : undefined)

this.$connect().then(() => {
this.logger.info('Connected to Prisma')
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-config-tempo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"eslint-plugin-require-extensions": "^0.1.3",
"eslint-plugin-typescript-sort-keys": "^2.3.0",
"eslint-plugin-unused-imports": "^3.0.0",
"prettier": "^3.0.0"
"prettier": "^3.0.0",
"tsconfig": "workspace:^"
}
}
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
],
"devDependencies": {
"eslint-config-tempo": "workspace:^",
"tsconfig": "workspace:^",
"tsup": "^7.1.0"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"build": {
"dependsOn": [
"^build",
"db:generate"
"db:generate"
],
"outputs": [
"dist/**",
Expand Down Expand Up @@ -71,4 +71,4 @@
"cache": false
}
}
}
}
Loading

0 comments on commit 9d15ac9

Please sign in to comment.