-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Dockerfile to match Next.js example closely, use "standalone" output, and with 40% smaller image size. #355
base: main
Are you sure you want to change the base?
Conversation
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 |
Appreciate this contribution a lot @jckw. Couple of notes:
|
**/node_modules | ||
**/.next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing **/<folder>
here? Wouldn't simply <folder>
do the same thing?
Ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Surprising that this isn't mentioned in the official docker docs. Thank you for the reference.
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-arg
s when building the imagenpx
to run prisma since this is slow on startup