From 6c6da94fa65306059b405445a4b5d76483c9bbc9 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 19 Nov 2021 10:57:00 -0500 Subject: [PATCH 1/8] add build args and break out Prisma Studio --- docker-compose.yaml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 5e6c4cf..895a06e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,15 +10,34 @@ services: ports: - 5432:5432 calendso: - build: . + build: + context: . + dockerfile: Dockerfile + args: + - BASE_URL=${BASE_URL} + - NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL} + image: calendso/docker restart: always ports: - 3000:3000 + env_file: .env + environment: + - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB} + depends_on: + - db + studio: + image: calendso/docker + restart: always + ports: - 5555:5555 env_file: .env environment: - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB} depends_on: - db + command: + - npx + - prisma + - studio volumes: database-data: \ No newline at end of file From 097f9177b3f90428b4440a4716895f4f61a6f3f2 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 19 Nov 2021 10:57:57 -0500 Subject: [PATCH 2/8] add build args and temporarily remove alpine --- Dockerfile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c96f1aa..7901afe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,36 @@ -FROM node:14-alpine as deps +FROM node:14 as deps -RUN apk add --no-cache libc6-compat WORKDIR /app COPY calendso/package.json calendso/yarn.lock ./ COPY calendso/prisma prisma RUN yarn install --frozen-lockfile -FROM node:14-alpine as builder +FROM node:14 as builder + WORKDIR /app +ARG BASE_URL +ENV BASE_URL $BASE_URL +ARG NEXT_PUBLIC_APP_URL +ENV NEXT_PUBLIC_APP_URL $NEXT_PUBLIC_APP_URL + COPY calendso . + COPY --from=deps /app/node_modules ./node_modules RUN yarn build && yarn install --production --ignore-scripts --prefer-offline -FROM node:14-alpine as runner +FROM node:14 as runner WORKDIR /app ENV NODE_ENV production +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/prisma ./prisma +COPY --from=builder /app/scripts ./scripts COPY --from=builder /app/next.config.js ./ COPY --from=builder /app/next-i18next.config.js ./ COPY --from=builder /app/public ./public COPY --from=builder /app/.next ./.next -COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json -COPY --from=builder /app/prisma ./prisma COPY scripts scripts + EXPOSE 3000 CMD ["/app/scripts/start.sh"] From 8194e321818957e9eb9f60d7f6b08b5adbc34cd9 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 19 Nov 2021 10:58:26 -0500 Subject: [PATCH 3/8] add missing env var samples --- .env.example | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.env.example b/.env.example index 33e0384..5d84939 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,13 @@ +# Set this value to 'agree' to accept our license: +# LICENSE: https://github.com/calendso/calendso/blob/main/LICENSE +# +# Summary of terms: +# - The codebase has to stay open source, whether it was modified or not +# - You can not repackage or sell the codebase +# - Acquire a commercial license to remove these terms by emailing: license@cal.com +NEXT_PUBLIC_LICENSE_CONSENT='' +LICENSE='' + POSTGRES_USER=unicorn_user POSTGRES_PASSWORD=magical_password POSTGRES_DB=calendso @@ -30,3 +40,6 @@ EMAIL_SERVER_PASSWORD='email_password' # Encryption key that will be used to encrypt CalDAV credentials, choose a random string, for example with `dd if=/dev/urandom bs=1K count=1 | md5sum` CALENDSO_ENCRYPTION_KEY='' + +JWT_SECRET=secret +NODE_ENV=production \ No newline at end of file From 985f5a8b4378089c176b220a581762ecd6fab2f2 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 19 Nov 2021 10:59:45 -0500 Subject: [PATCH 4/8] remove quotes from env sample --- .env.example | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 5d84939..e8207d7 100644 --- a/.env.example +++ b/.env.example @@ -12,10 +12,10 @@ POSTGRES_USER=unicorn_user POSTGRES_PASSWORD=magical_password POSTGRES_DB=calendso DATABASE_HOST=db:5432 -DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB}" -GOOGLE_API_CREDENTIALS='secret' -BASE_URL='http://localhost:3000' -NEXTAUTH_URL='http://localhost:3000' +DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB} +GOOGLE_API_CREDENTIALS={} +BASE_URL=http://localhost:3000 +NEXTAUTH_URL=http://localhost:3000 # Remove this var if you don't want Calendso to collect anonymous usage NEXT_PUBLIC_TELEMETRY_KEY=js.2pvs2bbpqq1zxna97wcml.oi2jzirnbj1ev4tc57c5r @@ -30,16 +30,16 @@ ZOOM_CLIENT_SECRET= # E-mail settings # Configures the global From: header whilst sending emails. -EMAIL_FROM='notifications@example.com' +EMAIL_FROM=notifications@example.com # Configure SMTP settings (@see https://nodemailer.com/smtp/). -EMAIL_SERVER_HOST='smtp.example.com' +EMAIL_SERVER_HOST=smtp.example.com EMAIL_SERVER_PORT=587 -EMAIL_SERVER_USER='email_user' -EMAIL_SERVER_PASSWORD='email_password' +EMAIL_SERVER_USER=email_user +EMAIL_SERVER_PASSWORD=email_password # Encryption key that will be used to encrypt CalDAV credentials, choose a random string, for example with `dd if=/dev/urandom bs=1K count=1 | md5sum` -CALENDSO_ENCRYPTION_KEY='' +CALENDSO_ENCRYPTION_KEY= JWT_SECRET=secret NODE_ENV=production \ No newline at end of file From 3118d8fccb737387a02a56d34fb14005bdb61baa Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Fri, 19 Nov 2021 11:00:02 -0500 Subject: [PATCH 5/8] remove quotes from env sample --- .env.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index e8207d7..7a986cc 100644 --- a/.env.example +++ b/.env.example @@ -5,8 +5,8 @@ # - The codebase has to stay open source, whether it was modified or not # - You can not repackage or sell the codebase # - Acquire a commercial license to remove these terms by emailing: license@cal.com -NEXT_PUBLIC_LICENSE_CONSENT='' -LICENSE='' +NEXT_PUBLIC_LICENSE_CONSENT= +LICENSE= POSTGRES_USER=unicorn_user POSTGRES_PASSWORD=magical_password From 930f0cf56abacbc4ac566c4bca67beda39a9ecee Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Mon, 22 Nov 2021 13:53:02 -0500 Subject: [PATCH 6/8] add remark about jwt --- .env.example | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 7a986cc..3277a47 100644 --- a/.env.example +++ b/.env.example @@ -41,5 +41,7 @@ EMAIL_SERVER_PASSWORD=email_password # Encryption key that will be used to encrypt CalDAV credentials, choose a random string, for example with `dd if=/dev/urandom bs=1K count=1 | md5sum` CALENDSO_ENCRYPTION_KEY= +# It is highly recommended that the JWT secret must be overridden and very unique JWT_SECRET=secret -NODE_ENV=production \ No newline at end of file + +NODE_ENV=production From 39acc564b3c8e56a15f81d8dfb82fe6e007f6109 Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Mon, 22 Nov 2021 15:13:17 -0500 Subject: [PATCH 7/8] update NEXTAUTH_URL to NEXT_PUBLIC_APP_URL to match calendso sample --- .env.example | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 3277a47..a27d0d6 100644 --- a/.env.example +++ b/.env.example @@ -8,14 +8,15 @@ NEXT_PUBLIC_LICENSE_CONSENT= LICENSE= +BASE_URL=http://localhost:3000 +NEXT_PUBLIC_APP_URL=http://localhost:3000 + POSTGRES_USER=unicorn_user POSTGRES_PASSWORD=magical_password POSTGRES_DB=calendso DATABASE_HOST=db:5432 DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB} GOOGLE_API_CREDENTIALS={} -BASE_URL=http://localhost:3000 -NEXTAUTH_URL=http://localhost:3000 # Remove this var if you don't want Calendso to collect anonymous usage NEXT_PUBLIC_TELEMETRY_KEY=js.2pvs2bbpqq1zxna97wcml.oi2jzirnbj1ev4tc57c5r From 793eba4a5f80b6367cd4d6b45d01a8533b1dc35f Mon Sep 17 00:00:00 2001 From: Colin Griffin Date: Mon, 22 Nov 2021 15:22:04 -0500 Subject: [PATCH 8/8] add remarks about optional studio service --- docker-compose.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 895a06e..47aa0eb 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -25,6 +25,7 @@ services: - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DATABASE_HOST}/${POSTGRES_DB} depends_on: - db +# Optional use of Prisma Studio. In production, comment out or remove the section below to prevent unwanted access to your database. studio: image: calendso/docker restart: always @@ -39,5 +40,6 @@ services: - npx - prisma - studio +# END SECTION: Optional use of Prisma Studio. volumes: - database-data: \ No newline at end of file + database-data: