Skip to content

Commit

Permalink
chore: add DIRECT_URL to docs, github actions, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
PJColombo committed Feb 25, 2025
1 parent 4e7fc92 commit b35e86e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# We use dotenv to load Prisma from Next.js' .env file
# @see https://www.prisma.io/docs/reference/database-reference/connection-urls
DATABASE_URL=postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public
DIRECT_URL=postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public

BLOBSCAN_WEB_TAG=next
BLOBSCAN_API_TAG=next
Expand Down
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
COMPOSE_FILE=docker-compose.local.yml
DATABASE_URL=postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public
DIRECT_URL=postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public


BLOBSCAN_API_BASE_URL=http://localhost:3001

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
DATABASE_URL: "postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public"
DIRECT_URL: "postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public"

jobs:
changesets:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
DATABASE_URL: "postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public"
DIRECT_URL: "postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public"

jobs:
release_docker:
Expand Down Expand Up @@ -80,6 +81,7 @@ jobs:
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
DATABASE_URL=${{ env.DATABASE_URL }}
DIRECT_URL=${{ env.DIRECT_URL }}
- name: Extract metadata (tags, labels) for Docker (Web)
id: meta_web
Expand All @@ -104,3 +106,4 @@ jobs:
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
DATABASE_URL=${{ env.DATABASE_URL }}
DIRECT_URL=${{ env.DIRECT_URL }}
3 changes: 3 additions & 0 deletions .github/workflows/docker_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
DATABASE_URL: postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public
DIRECT_URL: postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public

jobs:
release_docker:
Expand Down Expand Up @@ -73,6 +74,7 @@ jobs:
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
DATABASE_URL=${{ env.DATABASE_URL }}
DIRECT_URL=${{ env.DIRECT_URL }}
- name: Build and push (web)
uses: docker/build-push-action@v6.5.0
Expand All @@ -86,3 +88,4 @@ jobs:
BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
DATABASE_URL=${{ env.DATABASE_URL }}
DIRECT_URL=${{ env.DIRECT_URL }}
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ FROM deps AS web-builder
WORKDIR /app

ARG DATABASE_URL
ARG DIRECT_URL

ENV NEXT_BUILD_OUTPUT=standalone
ENV NEXT_TELEMETRY_DISABLED=1
Expand All @@ -49,7 +50,7 @@ COPY --from=deps /prepare/web/full .

# Copy original which includes pipelines
COPY --from=deps /prepare/turbo.json .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store DATABASE_URL=${DATABASE_URL} pnpm build --filter=@blobscan/web
RUN --mount=type=cache,id=pnpm,target=/pnpm/store DATABASE_URL=${DATABASE_URL} DIRECT_URL=${DIRECT_URL} pnpm build --filter=@blobscan/web

# stage: web
FROM base AS web
Expand Down Expand Up @@ -83,6 +84,8 @@ FROM deps AS api-builder
WORKDIR /app

ARG DATABASE_URL
ARG DIRECT_URL


COPY --from=deps /prepare/api/json .
COPY --from=deps /prepare/api/pnpm-lock.yaml .
Expand All @@ -94,7 +97,7 @@ COPY --from=deps /prepare/api/full .

# Copy original which includes pipelines
COPY --from=deps /prepare/turbo.json .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store DATABASE_URL=${DATABASE_URL} pnpm build --filter=@blobscan/rest-api-server
RUN --mount=type=cache,id=pnpm,target=/pnpm/store DATABASE_URL=${DATABASE_URL} DIRECT_URL=${DIRECT_URL} pnpm build --filter=@blobscan/rest-api-server

# stage: api
FROM base AS api
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/src/app/docs/environment/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ nextjs:
| Variable | Description | Required | Default value |
| -------------------------------------- | ------------------------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DATABASE_URL` | PostgreSQL database URI | Yes | (empty) |
| `DIRECT_URL` | Direct connection to the database used by Prisma CLI for e.g. migrations. | Yes | (empty) |
| `FEEDBACK_WEBHOOK_URL` | Discord webhook URL for feedback | No | (empty) |
| `PUBLIC_NETWORK_NAME` | Network name | No | mainnet |
| `PUBLIC_EXPLORER_BASE_URL` | Block explorer URL | No | `https://etherscan.io` |
Expand All @@ -33,6 +34,7 @@ nextjs:
| ------------------------------------ | -------------------------------------------------------------------------------------------------- | ------------------------------- | ------------------------------ |
| `CHAIN_ID` | EVM chain id | Yes | `1` |
| `DATABASE_URL` | Postgresql database URI | Yes | (empty) |
| `DIRECT_URL` | Direct connection to the database used by Prisma CLI for e.g. migrations. | Yes | (empty) |
| `REDIS_URI` | Redis host | Yes | `redis://localhost:6379/1` |
| `SECRET_KEY` | Shared key used for JWT authentication with the indexer | Yes | (empty) |
| `NETWORK_NAME` | Network's name (valid values are: `mainnet`, `holesky`, `sepolia`, `gnosis`, `chiado`, `devnet`) | No | `mainnet` |
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const env = createEnv({
*/
server: {
DATABASE_URL: z.string().url(),
DIRECT_URL: z.string().url(),
FEEDBACK_WEBHOOK_URL: z.string().optional(),
NODE_ENV: z.enum(["development", "test", "production"]),
METRICS_ENABLED: booleanSchema.default("false"),
Expand All @@ -73,6 +74,7 @@ export const env = createEnv({
*/
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
DIRECT_URL: process.env.DIRECT_URL,
FEEDBACK_WEBHOOK_URL: process.env.FEEDBACK_WEBHOOK_URL,
METRICS_ENABLED: process.env.METRICS_ENABLED,
NODE_ENV: process.env.NODE_ENV,
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/deploy_vercel_env.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
environment="production"
variables="CHAIN_ID PUBLIC_EXPLORER_BASE_URL PUBLIC_NETWORK_NAME PUBLIC_SUPPORTED_NETWORKS POSTGRES_STORAGE_ENABLED SWARM_STORAGE_ENABLED GOOGLE_STORAGE_ENABLED DATABASE_URL SECRET_KEY"
variables="CHAIN_ID PUBLIC_EXPLORER_BASE_URL PUBLIC_NETWORK_NAME PUBLIC_SUPPORTED_NETWORKS POSTGRES_STORAGE_ENABLED SWARM_STORAGE_ENABLED GOOGLE_STORAGE_ENABLED DATABASE_URL DIRECT_URL SECRET_KEY"

# other not so recently updated variables
# o_vars="METRICS_ENABLED BEE_ENDPOINT GOOGLE_SERVICE_KEY GOOGLE_STORAGE_BUCKET_NAME GOOGLE_STORAGE_PROJECT_ID"
Expand Down
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"CHAIN_ID",
"CI",
"DATABASE_URL",
"DIRECT_URL",
"FEEDBACK_WEBHOOK_URL",
"FILE_SYSTEM_STORAGE_ENABLED",
"FILE_SYSTEM_STORAGE_PATH",
Expand Down

0 comments on commit b35e86e

Please sign in to comment.