Skip to content

Commit

Permalink
Add Dockerfile (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
imxeno authored May 19, 2024
1 parent 4abcc13 commit d0fa7ad
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
node_modules
.turbo

# Output of the build
dist

# Turbo
.turbo
out

# Prisma generated files
**/prisma/client

# Environment variables
.env*
!.env.example
43 changes: 43 additions & 0 deletions apps/bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM node:20-alpine AS base

# Base with turbo dependencies (we are using Alpine Linux)
FROM base AS libc6-base
RUN apk add --no-cache libc6-compat
RUN apk update

FROM libc6-base AS pruner
WORKDIR /app
RUN npm add -g turbo
COPY . .

# Generate a partial monorepo with a pruned lockfile for @mist/bot
RUN turbo prune @mist/bot --docker

# Add lockfile and package.json's of isolated subworkspace
FROM libc6-base AS builder
WORKDIR /app

# Install dev dependencies
COPY .gitignore .gitignore
COPY --from=pruner /app/out/json/ .
RUN corepack enable
RUN pnpm install

# Build the project
COPY --from=pruner /app/out/full/ .
RUN pnpm build --filter=@mist/bot...

# Prune dev dependencies
RUN pnpm prune --prod

FROM base AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs

COPY --from=builder /app/ .

CMD node apps/bot/dist/main.js

0 comments on commit d0fa7ad

Please sign in to comment.