fp/d.packages.dockerfile

43 lines
1.6 KiB
Plaintext
Raw Normal View History

2024-07-06 08:49:51 +00:00
## This dockerfile creates multiple docker images.
## Because we are using monorepo with pnpm workspaces, we have many npm packages in this single git repo.
## Some of these packages in the monorepo depend on other packages in the monorepo.
## In order to build these individual packages which inter-depend on eachother,
## all of the dependent code must be present in the build.
##
## Below, COPY . /usr/src/app copies all the app code into the build context.
## Because we use Tilt, only specific path directories are visible to docker. This helps with build performance.
## When a new package becomes a dependency, we need to update our Tiltfile to include the package directory.
## Tiltfile example of docker_build() args which include `scout` and `next` packages.
## `only=['./pnpm-lock.yaml', './package.json', './packages/scout', './packages/next'],`
##
##
FROM node:20 AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS build
ENV NODE_ENV=production
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN mkdir -p /prod/scout
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm deploy --filter=scout --prod /prod/scout
# RUN pnpm deploy --filter=bot --prod /prod/bot
FROM base AS scout-manager
COPY --from=build /prod/scout /app
WORKDIR /app
ENTRYPOINT ["pnpm"]
CMD ["run", "start:manager"]
FROM base AS scout-worker
COPY --from=build /prod/scout /app
COPY --from=build /usr/src/app/certs/letsencrypt-stg-root-x1.pem
ENV NODE_EXTRA_CA_CERTS "/app/certs/letsencrypt-stg-root-x1.pem"
WORKDIR /app
ENTRYPOINT ["pnpm"]
CMD ["run", "start:worker"]