This repository was archived by the owner on Oct 29, 2025. It is now read-only.
Create Dockerfile to match Next.js example closely, use "standalone" output, and with 40% smaller image size.#355
Open
jckw wants to merge 5 commits intocalcom:mainfrom
Open
Create Dockerfile to match Next.js example closely, use "standalone" output, and with 40% smaller image size.#355jckw wants to merge 5 commits intocalcom:mainfrom
jckw wants to merge 5 commits intocalcom:mainfrom
Conversation
1 task
Author
|
Note that if you want to run this now, you have to do a couple of things since the Cal build is broken (unrelated to these changes). diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index a8a755010..da807fa3b 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -158,6 +158,7 @@ const matcherConfigUserTypeEmbedRoute = {
/** @type {import("next").NextConfig} */
const nextConfig = {
+ output: "standalone",
experimental: {
// externalize server-side node_modules with size > 1mb, to improve dev mode performance/RAM usage
serverComponentsExternalPackages: ["next-i18next"],
diff --git a/package.json b/package.json
index 5bfff32c1..8903302fb 100644
--- a/package.json
+++ b/package.json
@@ -57,7 +57,7 @@
"lint:fix": "turbo run lint:fix",
"lint:report": "turbo run lint:report",
"lint": "turbo run lint",
- "postinstall": "husky install && turbo run post-install",
+ "postinstall": "echo 'Not running postinstall because it breaks docker'",
"pre-commit": "lint-staged",
"predev": "echo 'Checking env files'",
"prisma": "yarn workspace @calcom/prisma prisma",And then also run |
Contributor
|
Appreciate this contribution a lot @jckw. Couple of notes:
|
Comment on lines
+3
to
+5
| **/.github | ||
| **/node_modules | ||
| **/.next |
Member
There was a problem hiding this comment.
Why are we doing **/<folder> here? Wouldn't simply <folder> do the same thing?
Ref
Author
There was a problem hiding this comment.
I don't think that's true. Dockerignore works differently to gitignore and is a bit unintuitive because of that:
All paths are relative to the root
Member
There was a problem hiding this comment.
I see. Surprising that this isn't mentioned in the official docker docs. Thank you for the reference.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is an overhaul of the small calcom-docker repo that takes advantage of Next.js's new-ish "standalone" output to create smaller image sizes (1.03GB -> 636MB).
It also removes various miscellaneous files in the repo that make using Docker more confusing.
Background: why this PR is needed
I think there is a conversation to be had about what calcom-docker is for - is it for people running production applications, or for local development? A lot has changed in the Cal/Next.js/Docker landscape since most of this code was written.
My assumption is that in 2024, it is primarily for production applications - calcom/cal.com can easily be run locally, and building Docker images is no longer a pain for people on certain system architectures as it was before.
The first thing to note is that the Docker image build step has been failing to build for the last 2+ months and nothing has been done about it. This indicates that having a single standardised Docker image is not crucial for Cal (and I agree with this!).
All of this suggests that moving away from a single standardised Docker image that uses a few tricks to make it possible to use on different domains would be okay, and that having users build their own images is probably better for them and for Cal.
With this in mind, the Dockerfile should optimise a few things:
As it stands, the Docker image has a couple of tricks and complexities, useless lines, etc., that make it hard to work with.
Changes
This PR removes miscellaneous files that make this repo more confusing, and focuses on plain Docker with an improved Dockerfile.
The Dockerfiles is based off of the example that Next.js provides, which uses the
output: "standalone"feature in Next.js. Therefore this PR depends on a change to be merged in the calcom/cal.com repo.There are some large changes to be aware of, which can probably be replaced, but I removed for simplicity / maintainability:
--build-args when building the imagenpxto run prisma since this is slow on startup