Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
338f316
initial go
taterhead247 Mar 14, 2026
3d99254
initial 2
taterhead247 Mar 14, 2026
b322d6a
problem fixes
taterhead247 Mar 14, 2026
ec37444
readmes
taterhead247 Mar 14, 2026
d1d9adf
version matching
taterhead247 Mar 14, 2026
112bd52
format fixes
taterhead247 Mar 14, 2026
7de3cdb
more test/error fixes
taterhead247 Mar 14, 2026
b89d39b
lint fixes
taterhead247 Mar 14, 2026
c25c7a1
more package/auth ignores
taterhead247 Mar 14, 2026
7937713
migration plan
taterhead247 Mar 16, 2026
e9c7de7
more work
taterhead247 Mar 16, 2026
9887ac8
missed some
taterhead247 Mar 16, 2026
3f131a6
upgrade to next-auth 5
taterhead247 Mar 16, 2026
732057c
using root .env
taterhead247 Mar 16, 2026
0fe47b6
it's technically running!
taterhead247 Mar 16, 2026
8a8ed85
cleanup
taterhead247 Mar 16, 2026
2e2c1b6
signout
taterhead247 Mar 16, 2026
7962f21
sso package
taterhead247 Mar 16, 2026
4e20639
lint an dtypecheck cleanup, readme tweaks
taterhead247 Mar 17, 2026
35a9bed
very slight formatting
taterhead247 Mar 17, 2026
2491cbf
incorporated many good comments from copilot
taterhead247 Mar 17, 2026
b745edc
lint
taterhead247 Mar 17, 2026
6a479ae
got drizzle all ready
taterhead247 Mar 17, 2026
3ceb505
final comment from copilot
taterhead247 Mar 17, 2026
3367bc1
enterprised the github action variables
taterhead247 Mar 18, 2026
ab109bc
trying out environment variables
taterhead247 Mar 18, 2026
0df2d2e
rearranging variables for a brighter future
taterhead247 Mar 18, 2026
54d17ff
expanded health endpoint
taterhead247 Mar 18, 2026
6ecf14c
switching from dabase url to database pieces
taterhead247 Mar 18, 2026
0208bb5
variables
taterhead247 Mar 19, 2026
eef33b7
Add NEXTAUTH_URL to environment variables and refactor database conne…
taterhead247 Mar 19, 2026
af55f0d
cleanup env pusher script
taterhead247 Mar 20, 2026
4673ea2
Bump version to 1.0.3 in package.json and enhance logging in cloud-ru…
taterhead247 Mar 20, 2026
bac8a4f
Regenerate lock file after rebase
pstaylor-patrick Apr 8, 2026
559abb5
Address PR review feedback
pstaylor-patrick Apr 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/workflows/deploy-auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Deploy Auth

on:
push:
tags:
- "auth@*"

concurrency:
group: deploy-auth-${{ github.ref }}
cancel-in-progress: false

env:
IMAGE_NAME: f3-auth
STAGING_PROJECT: f3-authentication-staging
PROD_PROJECT: f3-authentication
AR_REPO: cloud-run-builds
REGION: us-east1
SERVICE_NAME: f3-auth

jobs:
# Wait for CI to pass on the tagged commit
ci-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Wait for CI checks
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.sha }}
check-regexp: "^(build|lint|typecheck|format-check|test-coverage)$"
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 15

build:
needs: ci-gate
runs-on: ubuntu-latest
environment: auth-staging
permissions:
contents: read
id-token: write
outputs:
image: ${{ steps.meta.outputs.image }}
version: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Authenticate to GCP (staging project for AR)
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ vars.WIF_PROVIDER }}
service_account: ${{ vars.WIF_SA }}

- uses: google-github-actions/setup-gcloud@v2

- name: Authorize Docker to Artifact Registry
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet

- name: Extract tag version
id: meta
run: |
TAG="${GITHUB_REF_NAME}" # e.g. auth@1.2.3
VERSION="${TAG#auth@}" # e.g. 1.2.3
IMAGE="${REGION}-docker.pkg.dev/${STAGING_PROJECT}/${AR_REPO}/${IMAGE_NAME}:${VERSION}"
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Build and push Docker image
run: |
docker build \
--file apps/auth/Dockerfile \
--tag "${{ steps.meta.outputs.image }}" \
.
docker push "${{ steps.meta.outputs.image }}"

deploy-staging:
needs: build
runs-on: ubuntu-latest
environment:
name: auth-staging
url: https://staging.auth.f3nation.com
permissions:
contents: read
id-token: write
steps:
- name: Authenticate to GCP (staging)
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ vars.WIF_PROVIDER }}
service_account: ${{ vars.WIF_SA }}

- name: Deploy to Cloud Run (staging)
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.SERVICE_NAME }}
image: ${{ needs.build.outputs.image }}
region: ${{ env.REGION }}
project_id: ${{ env.STAGING_PROJECT }}

deploy-production:
needs: [build, deploy-staging]
runs-on: ubuntu-latest
environment:
name: auth-production
url: https://auth.f3nation.com
permissions:
contents: read
id-token: write
steps:
- name: Authenticate to GCP (staging — pull image from staging AR)
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ vars.WIF_PROVIDER }}
service_account: ${{ vars.WIF_SA }}

- uses: google-github-actions/setup-gcloud@v2

- name: Promote image to production AR
run: |
STAGING_IMAGE="${{ needs.build.outputs.image }}"
PROD_IMAGE="${REGION}-docker.pkg.dev/${PROD_PROJECT}/${AR_REPO}/${IMAGE_NAME}:${STAGING_IMAGE##*:}"
gcloud auth configure-docker ${REGION}-docker.pkg.dev --quiet
docker pull "${STAGING_IMAGE}"
docker tag "${STAGING_IMAGE}" "${PROD_IMAGE}"
docker push "${PROD_IMAGE}"
echo "prod_image=${PROD_IMAGE}" >> "$GITHUB_ENV"

- name: Authenticate to GCP (prod)
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ vars.WIF_PROVIDER }}
service_account: ${{ vars.WIF_SA }}

- name: Deploy to Cloud Run (prod)
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.SERVICE_NAME }}
image: ${{ env.prod_image }}
region: ${{ env.REGION }}
project_id: ${{ env.PROD_PROJECT }}
21 changes: 21 additions & 0 deletions apps/auth/.env.cloud-run.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# .env.cloud-run.<staging|prod>
# Copy this file and populate with real values:
# cp .env.cloud-run.example .env.cloud-run.staging
# cp .env.cloud-run.example .env.cloud-run.prod

# ── Secrets (pushed to GCP Secret Manager) ──
DATABASE_HOST=host
DATABASE_USER=user
DATABASE_PASSWORD=pass
DATABASE_NAME=dbname

AUTH_SECRET=generate-a-random-secret
AUTH_JWT_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\"
SENDGRID_API_KEY=SG.xxxx
API_KEY=f3_xxxx

# ── Per-environment plain env vars ──
NEXTAUTH_URL=https://auth.f3nation.com
NEXT_PUBLIC_AUTH_URL=https://auth.f3nation.com
NEXT_PUBLIC_API_URL=https://api.f3nation.com
EMAIL_FROM=noreply@f3nation.com
62 changes: 62 additions & 0 deletions apps/auth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# ---------- Stage 1: Prune monorepo ----------
FROM node:20-alpine AS builder

ENV TURBO_TELEMETRY_DISABLED=1
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apk add --no-cache libc6-compat && apk update
WORKDIR /app

RUN corepack enable && corepack prepare pnpm@8.15.1 --activate
RUN pnpm add -g turbo@^1.12.3

COPY . .
RUN turbo prune f3-auth --docker

# ---------- Stage 2: Install + build ----------
FROM node:20-alpine AS installer

ENV NEXT_TELEMETRY_DISABLED=1
ENV TURBO_TELEMETRY_DISABLED=1
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apk add --no-cache libc6-compat openssl && apk update
WORKDIR /app

RUN corepack enable && corepack prepare pnpm@8.15.1 --activate
RUN pnpm add -g turbo@^1.12.3

# Install dependencies from pruned lockfile
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install --frozen-lockfile

# Copy source and build
COPY --from=builder /app/out/full/ .

ENV NODE_ENV=production
ENV CI=true
ENV SKIP_ENV_VALIDATION=true

RUN pnpm turbo build --filter=f3-auth

# ---------- Stage 3: Production runner ----------
FROM node:20-alpine AS runner

RUN apk add --no-cache libc6-compat openssl && apk update
WORKDIR /app

RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 auth

# Copy standalone output
COPY --from=installer --chown=auth:nodejs /app/apps/auth/.next/standalone ./
COPY --from=installer --chown=auth:nodejs /app/apps/auth/.next/static ./apps/auth/.next/static
COPY --from=installer --chown=auth:nodejs /app/apps/auth/public ./apps/auth/public

USER auth

ENV PORT=8080
EXPOSE 8080

CMD ["node", "apps/auth/server.js"]
Loading
Loading