68 lines
2.8 KiB
Docker
68 lines
2.8 KiB
Docker
## d.factory.dockerfile
|
|
##
|
|
## @futureporn/factory is the system component which processes video segments into a VOD.
|
|
## Factory 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/factory && mkdir -p /prod/factory
|
|
|
|
## Copy manfiests, lockfiles, and configs into docker context
|
|
COPY package.json pnpm-lock.yaml .npmrc .
|
|
# COPY ./packages/image/pnpm-lock.yaml ./packages/image/package.json ./packages/image/
|
|
# COPY ./packages/scout/pnpm-lock.yaml ./packages/scout/package.json ./packages/scout/
|
|
# COPY ./packages/storage/pnpm-lock.yaml ./packages/storage/package.json ./packages/storage/
|
|
# COPY ./packages/utils/pnpm-lock.yaml ./packages/utils/package.json ./packages/utils/
|
|
COPY ./packages/types/pnpm-lock.yaml ./packages/types/package.json ./packages/types/
|
|
COPY ./services/factory/pnpm-lock.yaml ./services/factory/package.json ./services/factory/
|
|
|
|
## 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/image/ ./packages/image/
|
|
# COPY ./packages/scout/ ./packages/scout/
|
|
# COPY ./packages/storage/ ./packages/storage/
|
|
# COPY ./packages/utils/ ./packages/utils/
|
|
COPY ./packages/types/ ./packages/types/
|
|
COPY ./services/factory/ ./services/factory/
|
|
# 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
|
|
## we have to build @futureporn/image first because other packages depend on it's built js files
|
|
## next we build everything else
|
|
# RUN pnpm --filter=@futureporn/image build
|
|
# RUN pnpm --filter=!@futureporn/image -r build
|
|
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/factory --prod /prod/factory
|
|
|
|
FROM install AS dev
|
|
WORKDIR /app/services/factory
|
|
RUN ls -lash
|
|
CMD ["run", "dev"]
|
|
|
|
FROM base AS factory
|
|
COPY --from=build /prod/factory .
|
|
RUN ls -la .
|
|
CMD ["start"]
|
|
|