fp/dockerfiles/scout.dockerfile

43 lines
1.8 KiB
Plaintext
Raw Normal View History

2024-07-18 18:42:54 +00:00
FROM node:20 AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
WORKDIR /app
2024-08-31 10:42:28 +00:00
RUN curl -s https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest | grep "browser_download_url.*yt-dlp_linux\"" | cut -d : -f 2,3 | tr -d "\"" | wget -q -O /usr/local/bin/yt-dlp -i - && chmod +x /usr/local/bin/yt-dlp
2024-08-27 07:11:24 +00:00
## @important If pnpm is downloading node during the build, that's a bandwidth-expensive mistake.
## Node already exists in the docker image at /usr/local/bin/node.
## We should use the node version that exists in the docker image.
## The only thing that should be downloaded by corepack is pnpm.
## The reason we explicitly set a pnpm version here is because we want to have pnpm cached.
## We haven't copied any .npmrc or package.json files at this point in the build, so corepack has no way of knowing which version to get.
## There might be a more optimal way of doing this that doesn't require syncing this version with the version in package.json
## but I'm not sure what that would look like.
##
## @important match the pnpm version between all pnpm workspace packages or multiple versions of pnpm will get installed (slow)
RUN corepack enable && corepack prepare pnpm@9.6.0 --activate
ENTRYPOINT ["pnpm"]
FROM base AS install
COPY pnpm-lock.yaml .npmrc package.json .
COPY ./services/scout/ ./services/scout/
COPY ./packages/types/ ./packages/types/
COPY ./packages/utils/ ./packages/utils/
2024-07-16 10:46:44 +00:00
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm fetch
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --recursive --frozen-lockfile --prefer-offline
2024-07-16 06:57:27 +00:00
2024-08-27 07:11:24 +00:00
FROM install AS build
RUN pnpm -r build
RUN pnpm deploy --filter=scout --prod /prod/scout
2024-07-18 18:42:54 +00:00
2024-07-16 06:57:27 +00:00
2024-08-27 07:11:24 +00:00
FROM install AS dev
WORKDIR /app/services/scout
CMD ["run", "dev"]
2024-08-27 07:11:24 +00:00
FROM base AS prod
COPY --from=build /prod/scout .
2024-08-27 07:11:24 +00:00
CMD ["run", "start"]