Skip to content

Commit 0ade7dc

Browse files
fix: docker image malfunctioning
Signed-off-by: GitHub <[email protected]>
1 parent 9992305 commit 0ade7dc

File tree

8 files changed

+62
-40
lines changed

8 files changed

+62
-40
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.env
2+
node_modules
3+
blazebuild/node_modules

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ COPY build_src ./build_src
1616
COPY eslint.config.mjs ./eslint.config.mjs
1717
COPY vitest.config.mjs ./vitest.config.mjs
1818
COPY tests ./tests
19+
COPY scripts ./scripts
1920

2021
RUN ./blazew build
2122

@@ -26,9 +27,11 @@ WORKDIR /app
2627
COPY --from=0 /app/node_modules ./node_modules
2728
COPY --from=0 /app/build ./build
2829
COPY --from=0 /app/package.json ./package.json
30+
COPY --from=0 /app/scripts ./scripts
31+
COPY drizzle ./drizzle
2932
COPY ecosystem.config.js ./ecosystem.config.js
3033
COPY .env.docke[r] ./.env
3134
COPY config ./config
3235

3336
EXPOSE 4000
34-
CMD ["npm", "run", "start:prod", "--", "--no-daemon"]
37+
CMD ["npm", "run", "start:docker"]

config/schema/config.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@
385385
}
386386
},
387387
"required": [
388-
"type",
389-
"duration"
388+
"type"
390389
],
391390
"additionalProperties": false
392391
},
@@ -698,12 +697,11 @@
698697
"12": [
699698
{
700699
"type": "mute",
701-
"duration": 7200000
702-
}
703-
],
704-
"*": [
700+
"duration": 7200000,
701+
"reason": "The system has detected that your messages might violate the rules."
702+
},
705703
{
706-
"type": "delete_message"
704+
"type": "clear"
707705
}
708706
]
709707
}

config/schema/system.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"sync_emojis": {
88
"type": "boolean",
9-
"default": false
9+
"default": true
1010
},
1111
"emoji_resolve_strategy": {
1212
"type": "string",

docker-compose.yml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
services:
2-
postgres:
3-
image: "postgres:15-alpine"
4-
restart: always
5-
environment:
6-
POSTGRES_USER: postgres
7-
POSTGRES_PASSWORD: root
8-
POSTGRES_DB: sudobot
9-
volumes:
10-
- pgdata:/var/lib/postgresql/data
2+
postgres:
3+
image: "postgres:15-alpine"
4+
restart: always
5+
environment:
6+
POSTGRES_USER: postgres
7+
POSTGRES_PASSWORD: root
8+
POSTGRES_DB: sudobot
9+
volumes:
10+
- pgdata:/var/lib/postgresql/data
11+
12+
bot:
13+
build: .
14+
ports:
15+
- 4000:4000
16+
volumes:
17+
- ./config:/app/config
18+
- ./logs:/app/logs
19+
- ./storage:/app/storage
20+
- ./tmp:/app/tmp
21+
- ./.migration_status:/app/.migration_status
22+
depends_on:
23+
- postgres
24+
25+
adminer:
26+
image: adminer
27+
restart: always
28+
ports:
29+
- 8080:8080
1130

12-
bot:
13-
build: .
14-
ports:
15-
- 4000:4000
16-
volumes:
17-
- ./config:/app/config
18-
- ./logs:/app/logs
19-
- ./storage:/app/storage
20-
- ./tmp:/app/tmp
21-
depends_on:
22-
- postgres
23-
24-
adminer:
25-
image: adminer
26-
restart: always
27-
ports:
28-
- 8080:8080
29-
3031
volumes:
31-
pgdata:
32+
pgdata:

ecosystem.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const config = {
1010
apps: [
1111
{
1212
name: "sudobot",
13-
script: "build/out/main.js",
13+
script: "build/out/main/typescript/main.js",
1414
env_production: {
1515
NODE_ENV: "production"
1616
},

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"scripts": {
4242
"start": "node build/out/main/typescript/main.js",
43-
"start:bun": "bun --tsconfig-override=tsconfig.bun.json src/bun.ts",
43+
"start:bun": "bun --tsconfig-override=tsconfig.bun.json src/main/typescript/bun.ts",
4444
"prepare": "husky && node -e \"const { symlinkSync, rmSync, existsSync } = require('fs'); const path = require('path'); const link = path.join(process.cwd(), 'node_modules/blazebuild'); if (existsSync(link)) { rmSync(link, { recursive: true }); } symlinkSync(path.join(process.cwd(), 'blazebuild'), link, 'dir');\"",
4545
"dev": "bun run src/main/typescript/bun.ts",
4646
"start:blazew": "node build/out/main/typescript/main.js",
@@ -52,7 +52,8 @@
5252
"gen:schema": "node scripts/generate-config-schema.js",
5353
"clean": "rm -frv build tsconfig.tsbuildinfo; make clean",
5454
"test": "vitest",
55-
"shell": "bun run src/main/typescript/shell.ts"
55+
"shell": "bun run src/main/typescript/shell.ts",
56+
"start:docker": "if [ ! -f /app/.migration_status ] || [ -z \"$(cat /app/.migration_status)\" ]; then node scripts/migrate.js; fi; npm start"
5657
},
5758
"_moduleAliases": {
5859
"@sudobot": "build/out",

scripts/migrate.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require("dotenv/config");
2+
3+
async function main() {
4+
const { drizzle } = await import(String("drizzle-orm/node-postgres"));
5+
const { migrate } = await import(String("drizzle-orm/node-postgres/migrator"));
6+
const { default: PG } = await import(String("pg"));
7+
8+
const pool = new PG.Pool({
9+
connectionString: process.env.DB_URL
10+
});
11+
12+
const db = drizzle(pool);
13+
await migrate(db, { migrationsFolder: "drizzle" });
14+
await pool.end();
15+
}
16+
17+
main();

0 commit comments

Comments
 (0)