Skip to content

Commit

Permalink
Update dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
tomouchuu committed Oct 8, 2023
1 parent c517dd1 commit f63a5c9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
42 changes: 33 additions & 9 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
FROM oven/bun:alpine
FROM oven/bun:alpine AS base

RUN apk add --no-cache g++ make py3-pip ffmpeg
FROM base AS builder
RUN apk add --no-cache libc6-compat g++ make py3-pip ffmpeg
RUN apk update

RUN pip3 install streamlink

WORKDIR /app

COPY package.json .
COPY bun.lockb .
COPY . .
RUN bunx turbo prune --scope @haishin/backend --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/bun.lockb ./bun.lockb
RUN bun install --production

COPY src src
COPY tsconfig.json .
# COPY public public
# Use build args to enable remote caching
ARG TURBO_TEAM
ENV TURBO_TEAM=$TURBO_TEAM

ARG TURBO_TOKEN
ENV TURBO_TOKEN=$TURBO_TOKEN

# Build the project
COPY --from=builder /app/out/full/ .
RUN bunx turbo run build --filter=@haishin/backend...

# Run the project
FROM base AS runner
WORKDIR /app

COPY --from=installer /app .

ENV NODE_ENV production
CMD ["bun", "src/index.ts"]
CMD ["bun", "apps/backend/src/index.ts"]

EXPOSE 3000
19 changes: 6 additions & 13 deletions apps/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ COPY turbo.json turbo.json
ARG GIT_REVISION
ENV HAISHIN_VERSION=$GIT_REVISION

ARG RTMP_CLIENT_API_URL
ENV RTMP_CLIENT_API_URL=$RTMP_CLIENT_API_URL
ENV NEXT_PUBLIC_RTMP_CLIENT_API_URL=$RTMP_CLIENT_API_URL
ARG BACKEND_URL
ENV BACKEND_URL=$BACKEND_URL
ENV NEXT_PUBLIC_BACKEND_URL=$BACKEND_URL

ARG WS_URL
ENV WS_URL=$WS_URL
Expand Down Expand Up @@ -61,9 +61,9 @@ RUN apk update
WORKDIR /app

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

COPY --from=installer /app/apps/frontend/next.config.js .
COPY --from=installer /app/apps/frontend/package.json .
Expand All @@ -74,11 +74,4 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/.next/standalone
COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/.next/static ./apps/frontend/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/frontend/public ./apps/frontend/public

# Ideally we'd just copy the @ffmpeg folder but since it's got the version+patch it seems a little difficult
COPY --from=installer --chown=nextjs:nodejs /app/node_modules/.pnpm/@[email protected]_patch_hash=ld7rzfw7iozpndvzizlt4sbpaa ./node_modules/.pnpm/@[email protected]_patch_hash=ld7rzfw7iozpndvzizlt4sbpaa
COPY --from=installer /app/packages/transcriber/node_modules/@ffmpeg/core ./packages/transcriber/node_modules/@ffmpeg/core

# Lastly copy the transcriber dists
COPY --from=installer /app/packages/transcriber/dist ./packages/transcriber/dist

CMD node apps/frontend/server.js

0 comments on commit f63a5c9

Please sign in to comment.