64 lines
2.5 KiB
Plaintext
64 lines
2.5 KiB
Plaintext
|
## d.build.dockerfile
|
||
|
##
|
||
|
## @futureporn/build is the system component which processes video segments into a VOD.
|
||
|
## Build does tasks such as thumbnail generation, video encoding, file transfers, strapi record creation, etc.
|
||
|
|
||
|
|
||
|
FROM node:20 AS base
|
||
|
ENV PNPM_HOME="/pnpm"
|
||
|
ENV PATH="$PNPM_HOME:$PATH"
|
||
|
WORKDIR /app
|
||
|
COPY --from=mwader/static-ffmpeg:7.0.2 /ffmpeg /usr/local/bin/
|
||
|
COPY --from=mwader/static-ffmpeg:7.0.2 /ffprobe /usr/local/bin/
|
||
|
RUN corepack enable && corepack prepare pnpm@9.6.0 --activate
|
||
|
ENTRYPOINT ["pnpm"]
|
||
|
|
||
|
FROM base AS install
|
||
|
WORKDIR /app
|
||
|
RUN mkdir -p /app/services/build && mkdir -p /prod/build
|
||
|
|
||
|
## Copy manfiests, lockfiles, and configs into docker context
|
||
|
COPY package.json pnpm-lock.yaml .npmrc .
|
||
|
COPY ./packages/utils/pnpm-lock.yaml ./packages/utils/package.json ./packages/utils/
|
||
|
COPY ./packages/fetchers/package.json ./packages/fetchers/pnpm-lock.yaml ./packages/fetchers/
|
||
|
COPY ./packages/storage/pnpm-lock.yaml ./packages/storage/package.json ./packages/storage/
|
||
|
COPY ./packages/types/pnpm-lock.yaml ./packages/types/package.json ./packages/types/
|
||
|
COPY ./services/build/pnpm-lock.yaml ./services/build/package.json ./services/build/
|
||
|
|
||
|
## Install npm packages
|
||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm fetch
|
||
|
## we install node-gyp explicitly in order for sharp to install properly
|
||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install -g node-gyp --prefer-offline
|
||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --recursive --frozen-lockfile --prefer-offline
|
||
|
## Copy package code into docker context
|
||
|
COPY ./packages/utils/ ./packages/utils/
|
||
|
COPY ./packages/fetchers/ ./packages/fetchers/
|
||
|
RUN ls -la /app/packages/utils/node_modules/prevvy/
|
||
|
RUn cat ./packages/utils/package.json
|
||
|
COPY ./packages/storage/ ./packages/storage/
|
||
|
COPY ./packages/types/ ./packages/types/
|
||
|
COPY ./services/build/ ./services/build/
|
||
|
# we are grabbing the mp4 files from capture so we can run tests with them
|
||
|
COPY ./services/capture/src/fixtures ./services/capture/src/fixtures
|
||
|
|
||
|
|
||
|
FROM install AS build
|
||
|
## Transpile TS into JS
|
||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm -r build
|
||
|
|
||
|
## Copy all production code into one place
|
||
|
## `pnpm deploy` copies all dependencies into an isolated node_modules directory inside the target dir
|
||
|
## @see https://pnpm.io/cli/deploy
|
||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm deploy --filter=@futureporn/build --prod /prod/build
|
||
|
|
||
|
FROM install AS dev
|
||
|
WORKDIR /app/services/build
|
||
|
RUN ls -lash
|
||
|
CMD ["run", "dev"]
|
||
|
|
||
|
FROM base AS prod
|
||
|
COPY --from=build /prod/build .
|
||
|
RUN ls -la .
|
||
|
CMD ["start"]
|
||
|
|