From d7e2497bd812d1be72313708ae9f121a0d731a58 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 20 May 2022 12:07:41 -0400 Subject: [PATCH 1/7] specify network name and add database_url to args --- docker-compose.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index e4a6a7d..af0630c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,6 +6,7 @@ volumes: networks: stack: + name: stack external: false services: @@ -26,6 +27,8 @@ services: - NEXT_PUBLIC_WEBAPP_URL=${NEXT_PUBLIC_WEBAPP_URL} - NEXT_PUBLIC_LICENSE_CONSENT=${NEXT_PUBLIC_LICENSE_CONSENT} - NEXT_PUBLIC_TELEMETRY_KEY=${NEXT_PUBLIC_TELEMETRY_KEY} + - DATABASE_URL=${DATABASE_URL} + network: stack restart: always networks: - stack From c3eeb3cfdfd981dfa1c6317e849b88974e95b834 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 20 May 2022 12:32:04 -0400 Subject: [PATCH 2/7] update readme instructions for build and run --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 33e0a1f..25eceb6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ For Production, for the time being, please checkout the repository and build/pus ## Requirements -Make sure you have `docker` & `docker compose` installed on the server / system. +Make sure you have `docker` & `docker compose` installed on the server / system. Both are installed by most docker utilities, including Docker Desktop and Rancher Desktop. Note: `docker compose` without the hyphen is now the primary method of using docker-compose, per the Docker documentation. @@ -54,19 +54,53 @@ Note: `docker compose` without the hyphen is now the primary method of using doc 4. Rename `.env.example` to `.env` and then update `.env` -5. Build and start Cal.com via docker compose +5. Build the Cal.com docker image: + + Note: Due to application configuration requirements, an available database is currently required during the build process. + + a) If hosting elsewhere, configure the `DATABASE_URL` in the .env file, and skip the next step + + b) If a local or temporary database is required, start a local database via docker compose. ```bash - docker compose up --build + docker compose up -d database ``` -6. (First Run) Open a browser to [http://localhost:5555](http://localhost:5555) to look at or modify the database content. +6. Build Cal.com via docker compose + + ```bash + docker compose build calcom + ``` + +7. Start Cal.com via docker compose + + (Most basic users, and for First Run) To run the complete stack, which includes a local Postgres database, Cal.com web app, and Prisma Studio: + + ```bash + docker compose up -d + ``` + + To run Cal.com web app and Prisma Studio against a remote database, ensure that DATABASE_URL is configured for an available database and run: + + ```bash + docker compose up -d calcom studio + ``` + + To run only the Cal.com web app, ensure that DATABASE_URL is configured for an available database and run: + + ```bash + docker compose up -d calcom + ``` + + **Note: to run in attached mode for debugging, remove `-d` from your desired run command.** + +8. (First Run) Open a browser to [http://localhost:5555](http://localhost:5555) to look at or modify the database content. a. Click on the `User` model to add a new user record. b. Fill out the fields (remembering to encrypt your password with [BCrypt](https://bcrypt-generator.com/)) and click `Save 1 Record` to create your first user. -7. Open a browser to [http://localhost:3000](http://localhost:3000) and login with your just created, first user. +9. Open a browser to [http://localhost:3000](http://localhost:3000) (or your appropriately configured NEXT_PUBLIC_WEBAPP_URL) and login with your just created, first user. ## Configuration @@ -77,10 +111,12 @@ These variables must be provided at the time of the docker build, and can be pro * NEXT_PUBLIC_WEBAPP_URL * NEXT_PUBLIC_LICENSE_CONSENT * NEXT_PUBLIC_TELEMETRY_KEY +* DATABASE_URL ### Important Run-time variables * NEXTAUTH_SECRET +* DATABASE_URL ## Git Submodules From fc2feee50201c1a74e5ab67098ddf642181c381a Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 20 May 2022 13:34:52 -0400 Subject: [PATCH 3/7] add test workflow for docker build --- .../docker-build-push-dockerhub-test.yml | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/docker-build-push-dockerhub-test.yml diff --git a/.github/workflows/docker-build-push-dockerhub-test.yml b/.github/workflows/docker-build-push-dockerhub-test.yml new file mode 100644 index 0000000..51ef9f8 --- /dev/null +++ b/.github/workflows/docker-build-push-dockerhub-test.yml @@ -0,0 +1,75 @@ +# This is a basic workflow to help you get started with Actions + +name: Build and push image to DockerHub + +# Controls when the workflow will run +on: + # Allow running workflow manually from the Actions tab + workflow_dispatch: + +# Leaving in example for releases. Initially we simply push to 'latest' +# on: + # release: + # types: [ created ] + + # # Allows you to run this workflow manually from the Actions tab + # workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: checkout + uses: actions/checkout@v2 + + - name: Git submodule update + run: | + git submodule update --init + + - name: Docker Login + # You may pin to the exact commit or the version. + # uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v1.10.0 + with: + # Username used to log against the Docker registry + username: ${{ secrets.DOCKER_HUB_USERNAME }} + # Password or personal access token used to log against the Docker registry + password: ${{ secrets.DOCKER_HUB_TOKEN }} + # Log out from the Docker registry at the end of a job + logout: true # optional, default is true + + - name: Set up Docker builder + id: buildx + uses: docker/setup-buildx-action@v1.6.0 + + - name: Start database + run: | + cp .env.example .env + + - name: Start database + run: | + docker compose up -d database + + - name: Build and push image + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: false + # The test image is /docker and is private. final image will be /calendso and public + tags: docker.io/${{ secrets.DOCKER_HUB_USERNAME }}/calendso:canary + network: stack + build-args: | + BASE_URL=http://localhost:3000 + NEXT_PUBLIC_APP_URL=http://localhost:3000 + DATABASE_URL=${DATABASE_URL} + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} From 00f74b0bd7d80255be170c48ab1b12d43c8995a4 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 20 May 2022 13:35:42 -0400 Subject: [PATCH 4/7] add cleanup step --- .github/workflows/docker-build-push-dockerhub-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-build-push-dockerhub-test.yml b/.github/workflows/docker-build-push-dockerhub-test.yml index 51ef9f8..ff5721c 100644 --- a/.github/workflows/docker-build-push-dockerhub-test.yml +++ b/.github/workflows/docker-build-push-dockerhub-test.yml @@ -71,5 +71,9 @@ jobs: NEXT_PUBLIC_APP_URL=http://localhost:3000 DATABASE_URL=${DATABASE_URL} + - name: Cleanup + run: | + docker compose down + - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} From fd3f83bb00609b087708c98b2853a2ba9dde4e2d Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 20 May 2022 13:36:56 -0400 Subject: [PATCH 5/7] rename temp test action --- .github/workflows/docker-build-push-dockerhub-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build-push-dockerhub-test.yml b/.github/workflows/docker-build-push-dockerhub-test.yml index ff5721c..775acb5 100644 --- a/.github/workflows/docker-build-push-dockerhub-test.yml +++ b/.github/workflows/docker-build-push-dockerhub-test.yml @@ -1,6 +1,6 @@ # This is a basic workflow to help you get started with Actions -name: Build and push image to DockerHub +name: Test actions image build # Controls when the workflow will run on: From f7ea2cfef41a49beaa89ee773177e437fbd0664d Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 20 May 2022 13:39:24 -0400 Subject: [PATCH 6/7] rename file to workaround github bug --- ...docker-build-push-dockerhub-test.yml => docker-build-test.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{docker-build-push-dockerhub-test.yml => docker-build-test.yml} (100%) diff --git a/.github/workflows/docker-build-push-dockerhub-test.yml b/.github/workflows/docker-build-test.yml similarity index 100% rename from .github/workflows/docker-build-push-dockerhub-test.yml rename to .github/workflows/docker-build-test.yml From 6de505cc908f47399856372eb5177aa6e78d9687 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 20 May 2022 13:41:26 -0400 Subject: [PATCH 7/7] add branch triggers --- .github/workflows/docker-build-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build-test.yml b/.github/workflows/docker-build-test.yml index 775acb5..3cf1c74 100644 --- a/.github/workflows/docker-build-test.yml +++ b/.github/workflows/docker-build-test.yml @@ -4,8 +4,10 @@ name: Test actions image build # Controls when the workflow will run on: + push: + branches: [main] # Allow running workflow manually from the Actions tab - workflow_dispatch: + workflow_dispatch: ~ # Leaving in example for releases. Initially we simply push to 'latest' # on: