Docker – How to Apply Custom Modifications to the codebase

I am using an open-source, self-hosted version of cal.com, deployed with Docker and docker-compose on a server.

Request:

How can I overcome the yarn build timeout issue or find an efficient way to build the application so that my code modifications are applied correctly? I would ideally like to not use yarn build at all.

I’ve created a custom Dockerfile to incorporate some additional changes to the codebase, such as modifying the welcome message. However, I’m encountering an issue during the build process:

  • When I include the yarn build command in the Dockerfile, the build process takes over 40 minutes and eventually times out during the @calcom/web#build step.
  • Without the yarn build command, the Docker image builds quickly, and I can see that the code changes exist inside the Docker container. However, the modifications are not reflected in the running application.

Problem:

I believe the yarn build step is necessary to compile the application with my code modifications, but it’s timing out and not completing successfully.

Question:

Is there an alternative way to apply these code changes without running into the yarn build timeout issue? How can I efficiently build the application with my modifications in a self-hosted production environment?

Any help or suggestions would be greatly appreciated.

Here is my Dockerfile:

ARG SOFTWARE_VERSION_TAG=latest
FROM calcom/cal.com:${SOFTWARE_VERSION_TAG}

RUN apt-get update && 
    apt-get install -y python3 python3-pip && 
    rm -rf /var/lib/apt/lists/*

RUN pip3 install --no-cache-dir --break-system-packages cyrtranslit

COPY ./patch.sh /calcom/
COPY ./convert.py /calcom/
COPY ./icons /calcom/app/web/public

# Applying custom changes to the code, like a different welcome message
RUN chmod +x /calcom/patch.sh
RUN chmod +x /calcom/convert.py

RUN /calcom/patch.sh

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
ARG NEXT_PUBLIC_API_V2_URL

ENV NEXT_PUBLIC_WEBAPP_URL=http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER 
    NEXT_PUBLIC_API_V2_URL=$NEXT_PUBLIC_API_V2_URL 
    NEXT_PUBLIC_LICENSE_CONSENT=$NEXT_PUBLIC_LICENSE_CONSENT 
    CALCOM_TELEMETRY_DISABLED=$CALCOM_TELEMETRY_DISABLED 
    DATABASE_URL=$DATABASE_URL 
    DATABASE_DIRECT_URL=$DATABASE_URL 
    NEXTAUTH_SECRET=${NEXTAUTH_SECRET} 
    CALENDSO_ENCRYPTION_KEY=${CALENDSO_ENCRYPTION_KEY} 
    NODE_OPTIONS=--max-old-space-size=${MAX_OLD_SPACE_SIZE} 
    BUILD_STANDALONE=true

RUN yarn config set httpTimeout 120000000

# This step times out after 40 minutes during the @calcom/web#build
RUN yarn build

And here is my docker-compose.yml:

services:
  database:
    container_name: database
    image: elestio/postgres:16
    restart: always
    volumes:
      - ./pgdata:/var/lib/postgresql/data/
    env_file: .env
    ports:
      - 172.17.0.1:5432:5432

  calcom:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        SOFTWARE_VERSION_TAG: ${SOFTWARE_VERSION_TAG}
    restart: always
    ports:
      - 172.17.0.1:6424:3000
    env_file: .env
    environment:
      - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB}
      - DATABASE_DIRECT_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB}
    depends_on:
      - database

  pgadmin4:
    image: elestio/pgadmin:latest
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: ${ADMIN_EMAIL}
      PGADMIN_DEFAULT_PASSWORD: ${ADMIN_PASSWORD}
      PGADMIN_LISTEN_PORT: 8080
    ports:
      - "172.17.0.1:8080:8080"
    volumes:
      - ./servers.json:/pgadmin4/servers.json

Additional Information:

  • Without the yarn build step, the build completes immediately, but the modifications are not effective in the running application.
  • Including yarn build causes the build to take too long and ultimately times out.

References: