Skip to content

Commit

Permalink
add healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasptsch committed Aug 29, 2024
1 parent 6ec358d commit 7c31ad8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Deps
# Base
FROM node:21-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

# Prod Dependencies
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

# Build
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

# Build Artifacts
FROM scratch AS extract
COPY --from=build /app/dist /dist

# Runner
# Pterodactyl Image
FROM base as pterodactyl
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
Expand All @@ -30,10 +33,13 @@ RUN adduser -H -D container -s /bin/bash
ENV USER=container HOME=/home/container
USER container

HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1

COPY entrypoint.sh /entrypoint.sh

CMD [ "/bin/bash", "/entrypoint.sh" ]

# Default Image
FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
Expand All @@ -43,4 +49,6 @@ ENV DATABASE_URL "file:/app/config/db.sqlite"
ARG VERSION
ENV VERSION=$VERSION

HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1

CMD [ "pnpm", "start" ]
9 changes: 9 additions & 0 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Get } from "@nestjs/common";
import { AppService } from "./app.service";

export class AppController {
@Get()
getOk(): string {
return "OK";
}
}
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { MqttModule } from "./features/mqtt/mqtt.module";
import { PrimaryModule } from "./features/primary/primary.module";
import { SecondaryModule } from "./features/secondary/secondary.module";
import { DrizzleModule } from "./features/drizzle/drizzle.module";
import { AppController } from "./app.controller";
@Module({
imports: [
ConfigModule.forRoot({
Expand All @@ -37,5 +38,6 @@ import { DrizzleModule } from "./features/drizzle/drizzle.module";
MqttModule,
],
providers: [AppService, InfoCommands],
controllers: [AppController],
})
export class AppModule {}

0 comments on commit 7c31ad8

Please sign in to comment.