-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caf2d93
commit 8ad507e
Showing
9 changed files
with
221 additions
and
250 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
runs-on: "ubuntu-latest" | ||
|
||
steps: | ||
|
||
- name: Checkout source | ||
uses: actions/checkout@v3 | ||
with: | ||
|
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,75 +1,91 @@ | ||
FROM node:18 as builder | ||
# syntax=docker/dockerfile:1 | ||
# ^ Syntax version >= 1.5 is needed for `ADD`ing a git repository. | ||
|
||
# Reference: | ||
# - https://github.com/calcom/docker/blob/main/Dockerfile | ||
# - https://cal.com/docs/introduction/quick-start/self-hosting/installation#development-setup-&-production-build | ||
# - https://cal.com/docs/introduction/quick-start/self-hosting/upgrading | ||
# - https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md | ||
# - https://github.com/docker/docker-bench-security/tree/master | ||
# - https://yarnpkg.com/cli/workspaces/focus#details | ||
|
||
# --------------------------------- | ||
FROM node:18-alpine as builder | ||
|
||
ARG CALCOM_BRANCH=v3.4.3 | ||
|
||
# Set this to '1' if you don't want Cal to collect anonymous usage | ||
ENV CALCOM_TELEMETRY_DISABLED=0 | ||
# CHECKPOINT_DISABLE disables Prisma's telemetry | ||
ENV CHECKPOINT_DISABLE=0 | ||
ENV NEXT_TELEMETRY_DISABLED=0 | ||
ENV NODE_ENV=production | ||
ENV STORYBOOK_DISABLE_TELEMETRY=0 | ||
|
||
WORKDIR /cal.com | ||
|
||
ADD --keep-git-dir=false https://github.com/calcom/cal.com.git#${CALCOM_BRANCH} /cal.com | ||
|
||
# Notice yarn telemetry can be set here. | ||
RUN \ | ||
--mount=type=cache,target=/caches \ | ||
yarn config set enableTelemetry 1 && \ | ||
yarn config set cacheFolder /caches/yarn && \ | ||
yarn config set httpTimeout 1200000 && \ | ||
yarn install | ||
|
||
# Set CI so that linting and type checking are skipped during the build. This is to lower the build time. Seems to have no other effects in Cal.com during build (currently). Defaults `yarn install` to use `--immutable`, which isn't desirable here because `yarn.lock` needs to be rebuilt, so it is set here after `yarn install` has already run. | ||
ENV CI=1 | ||
|
||
# Use a secret mount for the environment variables, to avoid passing in build args. The secrets are only stored in memory, not in the container layer. Tooling caches are preserved to speed future builds. | ||
RUN \ | ||
--mount=type=cache,target=/cal.com/apps/web/.next/cache \ | ||
--mount=type=cache,target=/cal.com/node_modules/.cache \ | ||
--mount=type=secret,id=calcom-environment,target=/cal.com/.env \ | ||
set -a && . .env && set +a && \ | ||
npx turbo run build --filter=@calcom/web... | ||
|
||
# The Next.js and Turbo caches are stored for future builds in the previous layer. Since neither tool allows moving its cache directory outside of the default location inside `/cal.com`, the directories are removed here so they don't get copied to the runner later. | ||
RUN rm -rf /cal.com/apps/web/.next/cache /cal.com/node_modules/.cache | ||
|
||
# --------------------------------- | ||
FROM node:18-alpine as runner | ||
WORKDIR /cal.com | ||
|
||
# Copy appropriate directories. | ||
COPY --from=builder --chown=node:node /cal.com/.yarn/ .yarn/ | ||
COPY --from=builder --chown=node:node /cal.com/apps/web/ apps/web/ | ||
COPY --from=builder --chown=node:node /cal.com/packages/ packages/ | ||
COPY --from=builder --chown=node:node /cal.com/node_modules/ node_modules/ | ||
|
||
# Copy individual files. | ||
COPY --from=builder --chown=node:node \ | ||
/cal.com/.yarnrc.yml \ | ||
/cal.com/package.json \ | ||
/cal.com/turbo.json \ | ||
/cal.com/yarn.lock \ | ||
/cal.com/ | ||
COPY --from=builder --chown=node:node /cal.com/packages/prisma/schema.prisma prisma/schema.prisma | ||
|
||
# Copy the scripts used to start the container, and make them executable. | ||
COPY --chmod=555 --chown=node:node \ | ||
scripts/start.sh \ | ||
scripts/wait-for-it.sh \ | ||
/cal.com/scripts/ | ||
|
||
# This symlink is not needed to build this way. Harmless to leave it in, but unlinking it cleans up a large warning in the logs. | ||
RUN unlink /cal.com/packages/prisma/.env | ||
|
||
# Set this to '1' if you don't want Cal to collect anonymous usage | ||
ENV CALCOM_TELEMETRY_DISABLED=0 | ||
ENV NEXT_TELEMETRY_DISABLED=0 | ||
ENV NODE_ENV=production | ||
ENV STORYBOOK_DISABLE_TELEMETRY=0 | ||
|
||
WORKDIR /calcom | ||
|
||
ARG NEXT_PUBLIC_LICENSE_CONSENT | ||
ARG CALCOM_TELEMETRY_DISABLED | ||
ARG DATABASE_URL | ||
ARG NEXTAUTH_SECRET=secret | ||
ARG CALENDSO_ENCRYPTION_KEY=secret | ||
ARG MAX_OLD_SPACE_SIZE=4096 | ||
|
||
ENV NEXT_PUBLIC_WEBAPP_URL=http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER \ | ||
NEXT_PUBLIC_LICENSE_CONSENT=$NEXT_PUBLIC_LICENSE_CONSENT \ | ||
CALCOM_TELEMETRY_DISABLED=$CALCOM_TELEMETRY_DISABLED \ | ||
DATABASE_URL=$DATABASE_URL \ | ||
NEXTAUTH_SECRET=${NEXTAUTH_SECRET} \ | ||
CALENDSO_ENCRYPTION_KEY=${CALENDSO_ENCRYPTION_KEY} \ | ||
NODE_OPTIONS=--max-old-space-size=${MAX_OLD_SPACE_SIZE} | ||
|
||
COPY calcom/package.json calcom/yarn.lock calcom/.yarnrc.yml calcom/playwright.config.ts calcom/turbo.json calcom/git-init.sh calcom/git-setup.sh ./ | ||
COPY calcom/.yarn ./.yarn | ||
COPY calcom/apps/web ./apps/web | ||
COPY calcom/packages ./packages | ||
COPY calcom/tests ./tests | ||
|
||
RUN yarn config set httpTimeout 1200000 && \ | ||
npx turbo prune --scope=@calcom/web --docker && \ | ||
yarn install && \ | ||
yarn db-deploy && \ | ||
yarn --cwd packages/prisma seed-app-store | ||
|
||
RUN yarn turbo run build --filter=@calcom/web | ||
|
||
# RUN yarn plugin import workspace-tools && \ | ||
# yarn workspaces focus --all --production | ||
RUN rm -rf node_modules/.cache .yarn/cache apps/web/.next/cache | ||
|
||
FROM node:18 as builder-two | ||
|
||
WORKDIR /calcom | ||
ARG NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000 | ||
|
||
ENV NODE_ENV production | ||
|
||
COPY calcom/package.json calcom/.yarnrc.yml calcom/yarn.lock calcom/turbo.json ./ | ||
COPY calcom/.yarn ./.yarn | ||
COPY --from=builder /calcom/node_modules ./node_modules | ||
COPY --from=builder /calcom/packages ./packages | ||
COPY --from=builder /calcom/apps/web ./apps/web | ||
COPY --from=builder /calcom/packages/prisma/schema.prisma ./prisma/schema.prisma | ||
COPY scripts scripts | ||
|
||
# Save value used during this build stage. If NEXT_PUBLIC_WEBAPP_URL and BUILT_NEXT_PUBLIC_WEBAPP_URL differ at | ||
# run-time, then start.sh will find/replace static values again. | ||
ENV NEXT_PUBLIC_WEBAPP_URL=$NEXT_PUBLIC_WEBAPP_URL \ | ||
BUILT_NEXT_PUBLIC_WEBAPP_URL=$NEXT_PUBLIC_WEBAPP_URL | ||
|
||
RUN scripts/replace-placeholder.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_WEBAPP_URL} | ||
|
||
FROM node:18 as runner | ||
|
||
|
||
WORKDIR /calcom | ||
COPY --from=builder-two /calcom ./ | ||
ARG NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000 | ||
ENV NEXT_PUBLIC_WEBAPP_URL=$NEXT_PUBLIC_WEBAPP_URL \ | ||
BUILT_NEXT_PUBLIC_WEBAPP_URL=$NEXT_PUBLIC_WEBAPP_URL | ||
|
||
ENV NODE_ENV production | ||
EXPOSE 3000 | ||
|
||
HEALTHCHECK --interval=30s --timeout=30s --retries=5 \ | ||
CMD wget --spider http://localhost:3000 || exit 1 | ||
|
||
CMD ["/calcom/scripts/start.sh"] | ||
USER node | ||
CMD ["/cal.com/scripts/start.sh"] |
Oops, something went wrong.