mirror of
https://github.com/undernightcore/dockerizalo.git
synced 2025-12-30 09:09:36 -06:00
feat: add clean zombie builds scripts
This commit is contained in:
@@ -6,6 +6,7 @@ COPY ./package.json /usr/local/app/
|
||||
COPY ./package-lock.json /usr/local/app/
|
||||
COPY ./src /usr/local/app/src
|
||||
COPY ./prisma /usr/local/app/prisma
|
||||
COPY ./scripts /usr/local/app/scripts
|
||||
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
@@ -16,6 +17,7 @@ WORKDIR /usr/local/app
|
||||
COPY --from=build /usr/local/app/node_modules /usr/local/app/node_modules
|
||||
COPY --from=build /usr/local/app/dist /usr/local/app/dist
|
||||
COPY --from=build /usr/local/app/prisma /usr/local/app/prisma
|
||||
COPY --from=build /usr/local/app/scripts /usr/local/app/scripts
|
||||
|
||||
RUN apt-get update && apt-get install -y git
|
||||
|
||||
@@ -28,4 +30,4 @@ RUN npx prisma generate
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD npx prisma migrate deploy && node dist/index.mjs
|
||||
CMD npx prisma migrate deploy && npm run zombie && node dist/index.mjs
|
||||
@@ -31,7 +31,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "tsx watch src/index.ts",
|
||||
"build": "pkgroll ."
|
||||
"build": "pkgroll .",
|
||||
"zombie": "tsx scripts/zombie.ts"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
|
||||
25
scripts/zombie.ts
Normal file
25
scripts/zombie.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// This script cleans any zombie builds that are left in BUILDING status
|
||||
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const clearZombieBuilds = async () => {
|
||||
const builds = await prisma.build.findMany({ where: { status: "BUILDING" } });
|
||||
|
||||
await prisma.$transaction(
|
||||
builds.map((build) =>
|
||||
prisma.build.update({
|
||||
where: { id: build.id },
|
||||
data: { status: "FAILED", finishedAt: build.updatedAt },
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return builds.length;
|
||||
};
|
||||
|
||||
clearZombieBuilds().then((builds) => {
|
||||
console.log(`Sucessfully fixed ${builds} builds`);
|
||||
process.exit(0);
|
||||
});
|
||||
Reference in New Issue
Block a user