From 70765001e82530a78ac1337ac57165b2203e1314 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 30 Mar 2024 22:44:23 +0000 Subject: [PATCH 1/6] feat: push to digital ocean registry --- .github/workflows/deploy-live.yml | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/deploy-live.yml diff --git a/.github/workflows/deploy-live.yml b/.github/workflows/deploy-live.yml new file mode 100644 index 0000000..69ea3f4 --- /dev/null +++ b/.github/workflows/deploy-live.yml @@ -0,0 +1,48 @@ +name: Deploy Production +env: + REPO_NAME: ${{ github.event.repository.name }} + REPO_OWNER: ${{ github.repository_owner }} +on: + workflow_dispatch: + release: + types: [created] + +jobs: + build_and_tag: + runs-on: ubuntu-latest + environment: Production + services: + docker: + image: docker:19.03.5-dind + options: --privileged + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: live + + - name: Build Docker image + run: | + docker build -t in-house-queue-site . + + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + + - name: Log in to DigitalOcean Container Registry with short-lived credentials + run: doctl registry login --expiry-seconds 600 + + - name: Get the latest release tag + id: latest_release + run: | + tag=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" "https://api.github.com/repos/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}/releases/latest" | jq -r ".tag_name") + echo "TAG=$tag" >> $GITHUB_ENV + + - name: Tag and push Docker image + run: | + export DO_REPOSITORY=${{ secrets.DO_REPO }} + TAG=${{ env.TAG }} + docker tag in-house-queue-site:latest $DO_REPOSITORY:$TAG + docker push $DO_REPOSITORY:$TAG \ No newline at end of file From b76bfa8cb6a28b9ddf8b529c404dfc83139eb4f2 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 30 Mar 2024 22:54:37 +0000 Subject: [PATCH 2/6] feat: add required env vars to make build succeed --- .github/workflows/deploy-live.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/deploy-live.yml b/.github/workflows/deploy-live.yml index 69ea3f4..d3ffda9 100644 --- a/.github/workflows/deploy-live.yml +++ b/.github/workflows/deploy-live.yml @@ -2,11 +2,19 @@ name: Deploy Production env: REPO_NAME: ${{ github.event.repository.name }} REPO_OWNER: ${{ github.repository_owner }} + DATABASE_URL: ${{ secrets.DATABASE_URL }} + NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }} + DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} + DISCORD_CLIENT_SECRET: ${{ secrets.DISCORD_CLIENT_SECRET }} + UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }} + UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }} + on: workflow_dispatch: release: types: [created] + jobs: build_and_tag: runs-on: ubuntu-latest From 2298aab87b6007bf6543169737cf4345d3245c6f Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 30 Mar 2024 22:57:35 +0000 Subject: [PATCH 3/6] feat: add required env vars to make build succeed --- .github/workflows/deploy-live.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-live.yml b/.github/workflows/deploy-live.yml index d3ffda9..0c86474 100644 --- a/.github/workflows/deploy-live.yml +++ b/.github/workflows/deploy-live.yml @@ -2,12 +2,6 @@ name: Deploy Production env: REPO_NAME: ${{ github.event.repository.name }} REPO_OWNER: ${{ github.repository_owner }} - DATABASE_URL: ${{ secrets.DATABASE_URL }} - NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }} - DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} - DISCORD_CLIENT_SECRET: ${{ secrets.DISCORD_CLIENT_SECRET }} - UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }} - UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }} on: workflow_dispatch: @@ -32,6 +26,13 @@ jobs: - name: Build Docker image run: | + DATABASE_URL=${{ secrets.DATABASE_URL }} + NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} + DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }} + DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }} + UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} + UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }} + docker build -t in-house-queue-site . - name: Install doctl From d751733a43efea96a49dae91a57e7784e4d9f402 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 30 Mar 2024 22:59:02 +0000 Subject: [PATCH 4/6] feat: add required env vars to make build succeed --- .github/workflows/deploy-live.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-live.yml b/.github/workflows/deploy-live.yml index b9d0562..750f23f 100644 --- a/.github/workflows/deploy-live.yml +++ b/.github/workflows/deploy-live.yml @@ -25,12 +25,12 @@ jobs: - name: Build Docker image run: | - DATABASE_URL=${{ secrets.DATABASE_URL }} - NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} - DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }} - DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }} - UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} - UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }} + export DATABASE_URL=${{ secrets.DATABASE_URL }} + export NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} + export DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }} + export DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }} + export UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} + export UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }} docker build -t in-house-queue-site . From b6e774d49969a43d839bb112becd218981afef63 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 30 Mar 2024 23:23:27 +0000 Subject: [PATCH 5/6] feat: add required env vars to make build succeed --- .github/workflows/deploy-live.yml | 13 +++++-------- Dockerfile | 12 +++++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-live.yml b/.github/workflows/deploy-live.yml index 750f23f..1dd7ffc 100644 --- a/.github/workflows/deploy-live.yml +++ b/.github/workflows/deploy-live.yml @@ -25,14 +25,11 @@ jobs: - name: Build Docker image run: | - export DATABASE_URL=${{ secrets.DATABASE_URL }} - export NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} - export DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }} - export DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }} - export UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} - export UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }} - - docker build -t in-house-queue-site . + docker build -t in-house-queue-site \ + --build-arg DATABASE_URL=${{ secrets.DATABASE_URL }} \ + --build-arg DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }} \ + --build-arg DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }} \ + . - name: Install doctl uses: digitalocean/action-doctl@v2 diff --git a/Dockerfile b/Dockerfile index e90cfd9..7966dd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,11 @@ FROM node:18-alpine AS base +# Define arguments +ARG DATABASE_URL +ARG DISCORD_CLIENT_ID +ARG DISCORD_CLIENT_SECRET + + # Install dependencies only when needed FROM base AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. @@ -38,7 +44,11 @@ RUN \ FROM base AS runner WORKDIR /app -ENV NODE_ENV production +ENV NODE_ENV=production \ + DATABASE_URL=$DATABASE_URL \ + DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID \ + DISCORD_CLIENT_SECRET=$DISCORD_CLIENT_SECRET + # Uncomment the following line in case you want to disable telemetry during runtime. # ENV NEXT_TELEMETRY_DISABLED 1 From 950667737850694fc54a311e6f58604826e6fa53 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 30 Mar 2024 23:32:27 +0000 Subject: [PATCH 6/6] feat: add required env vars to make build succeed --- .github/workflows/deploy-live.yml | 3 +++ Dockerfile | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/deploy-live.yml b/.github/workflows/deploy-live.yml index 1dd7ffc..6848885 100644 --- a/.github/workflows/deploy-live.yml +++ b/.github/workflows/deploy-live.yml @@ -27,8 +27,11 @@ jobs: run: | docker build -t in-house-queue-site \ --build-arg DATABASE_URL=${{ secrets.DATABASE_URL }} \ + --build-arg NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} \ --build-arg DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }} \ --build-arg DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }} \ + --build-arg UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} \ + --build-arg UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }} \ . - name: Install doctl diff --git a/Dockerfile b/Dockerfile index 7966dd2..8eea29c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,11 @@ FROM node:18-alpine AS base # Define arguments ARG DATABASE_URL +ARG NEXTAUTH_SECRET ARG DISCORD_CLIENT_ID ARG DISCORD_CLIENT_SECRET +ARG UPSTASH_REDIS_REST_URL +ARG UPSTASH_REDIS_REST_TOKEN # Install dependencies only when needed @@ -46,8 +49,11 @@ WORKDIR /app ENV NODE_ENV=production \ DATABASE_URL=$DATABASE_URL \ + NEXTAUTH_SECRET=$NEXTAUTH_SECRET \ DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID \ DISCORD_CLIENT_SECRET=$DISCORD_CLIENT_SECRET + UPSTASH_REDIS_REST_URL=$UPSTASH_REDIS_REST_URL \ + UPSTASH_REDIS_REST_TOKEN=$UPSTASH_REDIS_REST_TOKEN # Uncomment the following line in case you want to disable telemetry during runtime. # ENV NEXT_TELEMETRY_DISABLED 1