-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 . | ||
|
@@ -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 |