updated docker pipeline to include database migrations, added dummy table to verify the pipeline works
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m52s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m52s
This commit is contained in:
parent
66eddb9a2a
commit
1a50f73c74
8 changed files with 1246 additions and 2 deletions
|
|
@ -39,6 +39,7 @@ COPY packages/db/package.json ./packages/db/
|
|||
COPY --from=builder /app/apps/api/dist ./apps/api/dist
|
||||
COPY --from=builder /app/packages/shared/dist ./packages/shared/dist
|
||||
COPY --from=builder /app/packages/db/dist ./packages/db/dist
|
||||
COPY --from=builder /app/packages/db/drizzle ./packages/db/drizzle
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
EXPOSE 3000
|
||||
CMD ["node", "apps/api/dist/src/server.js"]
|
||||
CMD ["sh", "-c", "node packages/db/dist/src/migrate.js && node apps/api/dist/src/server.js"]
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ services:
|
|||
|
||||
api:
|
||||
container_name: lila-api
|
||||
user: "${UID}:${GID}"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./apps/api/Dockerfile
|
||||
|
|
@ -59,6 +60,7 @@ services:
|
|||
|
||||
web:
|
||||
container_name: lila-web
|
||||
user: "${UID}:${GID}"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./apps/web/Dockerfile
|
||||
|
|
|
|||
3
packages/db/drizzle/0009_rapid_cobalt_man.sql
Normal file
3
packages/db/drizzle/0009_rapid_cobalt_man.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
CREATE TABLE "dummy" (
|
||||
"id" serial PRIMARY KEY NOT NULL
|
||||
);
|
||||
1203
packages/db/drizzle/meta/0009_snapshot.json
Normal file
1203
packages/db/drizzle/meta/0009_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -64,6 +64,13 @@
|
|||
"when": 1776695279870,
|
||||
"tag": "0008_far_energizer",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "7",
|
||||
"when": 1776928720684,
|
||||
"tag": "0009_rapid_cobalt_man",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "rm -rf dist && tsc",
|
||||
"generate": "drizzle-kit generate",
|
||||
"migrate": "drizzle-kit migrate"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
index,
|
||||
boolean,
|
||||
integer,
|
||||
serial,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
import { sql, relations } from "drizzle-orm";
|
||||
|
|
@ -330,3 +331,5 @@ export const lobbyPlayersRelations = relations(lobby_players, ({ one }) => ({
|
|||
}),
|
||||
user: one(user, { fields: [lobby_players.userId], references: [user.id] }),
|
||||
}));
|
||||
|
||||
export const dummy = pgTable("dummy", { id: serial("id").primaryKey() });
|
||||
|
|
|
|||
25
packages/db/src/migrate.ts
Normal file
25
packages/db/src/migrate.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { config } from "dotenv";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
import { Pool } from "pg";
|
||||
import { resolve, dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
config({
|
||||
path: resolve(dirname(fileURLToPath(import.meta.url)), "../../../.env"),
|
||||
});
|
||||
|
||||
const pool = new Pool({ connectionString: process.env["DATABASE_URL"]! });
|
||||
const db = drizzle(pool);
|
||||
|
||||
console.log("starting database migrations...");
|
||||
|
||||
await migrate(db, {
|
||||
migrationsFolder: resolve(
|
||||
dirname(fileURLToPath(import.meta.url)),
|
||||
"../drizzle",
|
||||
),
|
||||
});
|
||||
|
||||
await pool.end();
|
||||
console.log("database migrations complete.");
|
||||
Loading…
Add table
Add a link
Reference in a new issue