fp/dockerfiles/factory.dockerfile

64 lines
2.5 KiB
Plaintext
Raw Normal View History

2024-08-10 00:28:37 +00:00
## 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/
2024-08-31 10:42:28 +00:00
RUN corepack enable && corepack prepare pnpm@9.6.0 --activate
2024-08-10 00:28:37 +00:00
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 .
2024-09-03 16:28:39 +00:00
COPY ./packages/utils/pnpm-lock.yaml ./packages/utils/package.json ./packages/utils/
2024-09-06 05:39:08 +00:00
COPY ./packages/fetchers/package.json ./packages/fetchers/pnpm-lock.yaml ./packages/fetchers/
2024-09-03 16:28:39 +00:00
COPY ./packages/storage/pnpm-lock.yaml ./packages/storage/package.json ./packages/storage/
2024-08-10 00:28:37 +00:00
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
2024-09-03 16:28:39 +00:00
COPY ./packages/utils/ ./packages/utils/
2024-09-06 05:39:08 +00:00
COPY ./packages/fetchers/ ./packages/fetchers/
2024-09-03 16:28:39 +00:00
RUN ls -la /app/packages/utils/node_modules/prevvy/
RUn cat ./packages/utils/package.json
COPY ./packages/storage/ ./packages/storage/
2024-08-10 00:28:37 +00:00
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
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"]