mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 12:04:02 +00:00
feat(infra): add docker image build and deploy pipeline (#13)
This commit is contained in:
40
apps/bot/Dockerfile
Normal file
40
apps/bot/Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
FROM oven/bun:1.3.10 AS deps
|
||||
WORKDIR /app
|
||||
|
||||
COPY bun.lock package.json tsconfig.base.json ./
|
||||
COPY apps/bot/package.json apps/bot/package.json
|
||||
COPY apps/miniapp/package.json apps/miniapp/package.json
|
||||
COPY packages/application/package.json packages/application/package.json
|
||||
COPY packages/config/package.json packages/config/package.json
|
||||
COPY packages/contracts/package.json packages/contracts/package.json
|
||||
COPY packages/db/package.json packages/db/package.json
|
||||
COPY packages/domain/package.json packages/domain/package.json
|
||||
COPY packages/observability/package.json packages/observability/package.json
|
||||
COPY packages/ports/package.json packages/ports/package.json
|
||||
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
FROM deps AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY apps ./apps
|
||||
COPY packages ./packages
|
||||
|
||||
RUN bun run --filter @household/bot build
|
||||
|
||||
FROM oven/bun:1.3.10 AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=8080
|
||||
|
||||
COPY --from=build /app/apps/bot/dist ./apps/bot/dist
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD bun -e "fetch('http://127.0.0.1:' + (process.env.PORT ?? '8080') + '/health').then((res) => process.exit(res.ok ? 0 : 1)).catch(() => process.exit(1))"
|
||||
|
||||
CMD ["bun", "apps/bot/dist/index.js"]
|
||||
34
apps/miniapp/Dockerfile
Normal file
34
apps/miniapp/Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
FROM oven/bun:1.3.10 AS deps
|
||||
WORKDIR /app
|
||||
|
||||
COPY bun.lock package.json tsconfig.base.json ./
|
||||
COPY apps/bot/package.json apps/bot/package.json
|
||||
COPY apps/miniapp/package.json apps/miniapp/package.json
|
||||
COPY packages/application/package.json packages/application/package.json
|
||||
COPY packages/config/package.json packages/config/package.json
|
||||
COPY packages/contracts/package.json packages/contracts/package.json
|
||||
COPY packages/db/package.json packages/db/package.json
|
||||
COPY packages/domain/package.json packages/domain/package.json
|
||||
COPY packages/observability/package.json packages/observability/package.json
|
||||
COPY packages/ports/package.json packages/ports/package.json
|
||||
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
FROM deps AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY apps/miniapp ./apps/miniapp
|
||||
|
||||
RUN bun run --filter @household/miniapp build
|
||||
|
||||
FROM nginx:1.27-alpine AS runtime
|
||||
|
||||
COPY apps/miniapp/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/apps/miniapp/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD wget -qO- http://127.0.0.1:8080/health >/dev/null || exit 1
|
||||
16
apps/miniapp/nginx.conf
Normal file
16
apps/miniapp/nginx.conf
Normal file
@@ -0,0 +1,16 @@
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location = /health {
|
||||
default_type application/json;
|
||||
return 200 '{"ok":true}';
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user