add docker health checks
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
||||
8
Justfile
Normal file
8
Justfile
Normal file
@ -0,0 +1,8 @@
|
||||
run *ARGS: build
|
||||
docker compose up {{ARGS}}
|
||||
|
||||
stop:
|
||||
docker compose down
|
||||
|
||||
build:
|
||||
docker compose build
|
||||
1
backend/.gitignore
vendored
1
backend/.gitignore
vendored
@ -1 +1,2 @@
|
||||
target/
|
||||
vendor/busybox_WGET
|
||||
|
||||
@ -21,7 +21,10 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
cargo build --release --bin nuchat --target-dir=/app/target
|
||||
|
||||
FROM gcr.io/distroless/cc AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/target/release/nuchat ./nuchat
|
||||
|
||||
ENTRYPOINT [ "./nuchat", "--host 0.0.0.0" ]
|
||||
ADD --chmod=a+x vendor/busybox_WGET /usr/bin/wget
|
||||
COPY --from=builder /app/target/release/nuchat /usr/bin/
|
||||
|
||||
# HEALTHCHECK --interval=5s --retries=1 --timeout=5s CMD ["wget", "-q", "--spider", "http://localhost:7000/healthcheck
|
||||
|
||||
ENTRYPOINT [ "nuchat", "--host", "0.0.0.0" ]
|
||||
|
||||
@ -3,10 +3,28 @@ services:
|
||||
build: ./ui
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_started
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://0.0.0.0:3000"]
|
||||
interval: 1s
|
||||
retries: 3
|
||||
timeout: 5s
|
||||
|
||||
backend:
|
||||
build: ./backend
|
||||
ports:
|
||||
- "7000:7000"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost:7000/healthcheck"]
|
||||
interval: 1s
|
||||
retries: 3
|
||||
timeout: 5s
|
||||
|
||||
db:
|
||||
image: postgres:17-alpine
|
||||
restart: unless-stopped
|
||||
@ -14,8 +32,11 @@ services:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_DB: nuchat
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d nuchat"]
|
||||
interval: 1s
|
||||
retries: 3
|
||||
timeout: 5s
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FROM node:24-slim AS base
|
||||
FROM node:24-alpine AS base
|
||||
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
@ -24,8 +24,9 @@ FROM base AS runner
|
||||
COPY --from=prod /app/node_modules /app/node_modules
|
||||
COPY --from=build /app/build build/
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE $PORT
|
||||
|
||||
CMD ["node", "build"]
|
||||
|
||||
Reference in New Issue
Block a user