-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes for projects using prisma orm (#497)
We may remove these fixes in future and allow developers to resolve these issues themselves through custom docker files. For now though, they have no impact on projects that aren't running prisma. Related issues can be found here: - prisma/docs#4365 - prisma/prisma#16901 (comment)
- Loading branch information
Showing
15 changed files
with
103 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,53 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM node:alpine as build | ||
|
||
ARG HANDLER | ||
|
||
# Python and make are required by certain native package build processes in NPM packages. | ||
ENV PYTHONUNBUFFERED=1 | ||
RUN apk add --update --no-cache python3 make g++ && ln -sf python3 /usr/bin/python | ||
RUN python3 -m ensurepip | ||
RUN pip3 install --no-cache --upgrade pip setuptools | ||
RUN apk add g++ make py3-pip | ||
|
||
RUN yarn global add typescript @vercel/ncc | ||
|
||
COPY . . | ||
WORKDIR /usr/app | ||
|
||
COPY package.json *.lock *-lock.json / | ||
|
||
RUN yarn import || echo Lockfile already exists | ||
RUN yarn import || echo "" | ||
|
||
RUN set -ex; yarn install --production --frozen-lockfile --cache-folder /tmp/.cache; rm -rf /tmp/.cache; | ||
RUN set -ex && \ | ||
yarn install --production --frozen-lockfile --cache-folder /tmp/.cache && \ | ||
rm -rf /tmp/.cache | ||
|
||
RUN test -f tsconfig.json || echo "{\"compilerOptions\":{\"esModuleInterop\":true,\"target\":\"es2015\",\"moduleResolution\":\"node\"}}" > tsconfig.json | ||
|
||
RUN ncc build ${HANDLER} -m --v8-cache -o lib/ | ||
COPY . . | ||
|
||
# make prisma external to bundle - https://github.com/prisma/prisma/issues/16901#issuecomment-1362940774 \ | ||
# TODO: remove when custom dockerfile support is available | ||
RUN \ | ||
--mount=type=cache,target=/tmp/ncc-cache \ | ||
ncc build ${HANDLER} -o lib/ -e .prisma/client -e @prisma/client -t | ||
|
||
FROM node:alpine as final | ||
|
||
WORKDIR /usr/app | ||
|
||
RUN apk update && \ | ||
apk add --no-cache ca-certificates && \ | ||
update-ca-certificates | ||
|
||
COPY --from=build "package.json" "package.json" | ||
|
||
COPY --from=build "node_modules/" "node_modules/" | ||
COPY package.json *.lock *-lock.json ./ | ||
|
||
COPY --from=build lib/ / | ||
RUN set -ex && \ | ||
yarn install --production --frozen-lockfile --cache-folder /tmp/.cache && \ | ||
rm -rf /tmp/.cache | ||
|
||
# Copy any other non-ignored assets to be included | ||
COPY . . | ||
|
||
ENTRYPOINT ["node", "index.js"] | ||
COPY --from=build /usr/app/lib/ ./lib/ | ||
|
||
# prisma fix for docker installs: https://github.com/prisma/docs/issues/4365 | ||
# TODO: remove when custom dockerfile support is available | ||
RUN test -d ./prisma && npx prisma generate || echo ""; | ||
|
||
ENTRYPOINT ["node", "lib/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters