fp/dockerfiles/build.dockerfile

64 lines
2.5 KiB
Plaintext
Raw Normal View History

2024-10-02 17:38:24 +00:00
## d.build.dockerfile
2024-08-10 00:28:37 +00:00
##
2024-10-02 17:38:24 +00:00
## @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.
2024-08-10 00:28:37 +00:00
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
2024-10-02 17:38:24 +00:00
RUN mkdir -p /app/services/build && mkdir -p /prod/build
2024-08-10 00:28:37 +00:00
## 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/
2024-10-02 17:38:24 +00:00
COPY ./services/build/pnpm-lock.yaml ./services/build/package.json ./services/build/
2024-08-10 00:28:37 +00:00
## 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/
2024-10-02 17:38:24 +00:00
COPY ./services/build/ ./services/build/
2024-08-10 00:28:37 +00:00
# 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
2024-10-02 17:38:24 +00:00
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm deploy --filter=@futureporn/build --prod /prod/build
2024-08-10 00:28:37 +00:00
FROM install AS dev
2024-10-02 17:38:24 +00:00
WORKDIR /app/services/build
2024-08-10 00:28:37 +00:00
RUN ls -lash
CMD ["run", "dev"]
2024-10-02 17:38:24 +00:00
FROM base AS prod
COPY --from=build /prod/build .
2024-08-10 00:28:37 +00:00
RUN ls -la .
CMD ["start"]