Skip to content

Commit 46a1810

Browse files
committed
Configure sentry for uploading and releasing during the publish webapp step
1 parent 5fe9a97 commit 46a1810

File tree

7 files changed

+62
-135
lines changed

7 files changed

+62
-135
lines changed

.github/workflows/publish-webapp.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,8 @@ jobs:
8686
BUILD_GIT_SHA=${{ steps.set_build_info.outputs.BUILD_GIT_SHA }}
8787
BUILD_GIT_REF_NAME=${{ steps.set_build_info.outputs.BUILD_GIT_REF_NAME }}
8888
BUILD_TIMESTAMP_SECONDS=${{ steps.set_build_info.outputs.BUILD_TIMESTAMP_SECONDS }}
89+
SENTRY_RELEASE=${{ steps.set_build_info.outputs.BUILD_GIT_SHA }}
90+
SENTRY_ORG=triggerdev
91+
SENTRY_PROJECT=trigger-cloud
92+
secrets: |
93+
sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}

apps/webapp/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"scripts": {
77
"build": "run-s build:** && pnpm run upload:sourcemaps",
88
"build:db:seed": "esbuild --platform=node --bundle --minify --format=cjs ./prisma/seed.ts --outdir=prisma",
9-
"build:remix": "remix build",
9+
"build:remix": "remix build --sourcemap",
1010
"build:server": "esbuild --platform=node --format=cjs ./server.ts --outdir=build --sourcemap",
11-
"build:instrument": "esbuild --platform=node --format=cjs ./instrument.server.ts --outdir=build --sourcemap",
11+
"build:sentry": "esbuild --platform=node --format=cjs ./sentry.server.ts --outdir=build --sourcemap",
1212
"dev": "cross-env PORT=3030 remix dev -c \"node ./build/server.js\"",
1313
"dev:worker": "cross-env NODE_PATH=../../node_modules/.pnpm/node_modules node ./build/server.js",
1414
"format": "prettier --write .",
@@ -217,6 +217,7 @@
217217
"@remix-run/testing": "^2.1.0",
218218
"@swc/core": "^1.3.4",
219219
"@swc/helpers": "^0.4.11",
220+
"@sentry/cli": "2.50.2",
220221
"@tailwindcss/forms": "^0.5.3",
221222
"@tailwindcss/typography": "^0.5.9",
222223
"@total-typescript/ts-reset": "^0.4.2",
@@ -278,4 +279,4 @@
278279
"engines": {
279280
"node": ">=16.0.0"
280281
}
281-
}
282+
}

apps/webapp/instrument.server.ts renamed to apps/webapp/sentry.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (process.env.SENTRY_DSN) {
2020
shutdownTimeout: 10,
2121

2222
serverName: process.env.SERVICE_NAME,
23-
environment: process.env.NODE_ENV,
23+
environment: process.env.APP_ENV,
2424

2525
integrations: [eventLoopBlockIntegration({ threshold: 1000 })],
2626
});

apps/webapp/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "./instrument.server";
1+
import "./sentry.server";
22

33
import { createRequestHandler } from "@remix-run/express";
44
import { broadcastDevReady, logDevReady } from "@remix-run/server-runtime";

apps/webapp/upload-sourcemaps.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/bash
2-
if [ -n "$SENTRY_ORG" ] && [ -n "$SENTRY_PROJECT" ] && [ -n "$SENTRY_AUTH_TOKEN" ]; then
3-
sentry-upload-sourcemaps --org $SENTRY_ORG --project $SENTRY_PROJECT --buildPath ./build
2+
set -euo pipefail
3+
4+
if [ -n "$SENTRY_ORG" ] && [ -n "$SENTRY_PROJECT" ] && [ -n "$SENTRY_AUTH_TOKEN" ] && [ -n "$SENTRY_RELEASE" ]; then
5+
sentry-cli releases new $SENTRY_RELEASE
6+
sentry-cli sourcemaps inject ./build
7+
sentry-cli sourcemaps upload ./build --release $SENTRY_RELEASE
48
else
59
echo "Skipping sourcemap upload: Missing required environment variables"
6-
echo "Required: SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN"
10+
echo "Required: SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN, SENTRY_RELEASE"
711
fi

docker/Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,20 @@ RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpx prisma@
4242

4343
## Builder (builds the webapp)
4444
FROM base AS builder
45+
RUN apt-get update && apt-get install -y openssl dumb-init ca-certificates
4546
WORKDIR /triggerdotdev
4647
# Corepack is used to install pnpm
4748
RUN corepack enable
4849

50+
ARG SENTRY_RELEASE
51+
ARG SENTRY_ORG
52+
ARG SENTRY_PROJECT
53+
# Remove SENTRY_AUTH_TOKEN from build args since we'll use secrets
54+
ENV SENTRY_RELEASE=${SENTRY_RELEASE} \
55+
SENTRY_ORG=${SENTRY_ORG} \
56+
SENTRY_PROJECT=${SENTRY_PROJECT}
57+
# Remove SENTRY_AUTH_TOKEN from env vars since it will be mounted as secret
58+
4959
# Goose and schemas
5060
COPY --from=goose_builder /go/bin/goose /usr/local/bin/goose
5161
RUN chmod +x /usr/local/bin/goose
@@ -60,7 +70,9 @@ RUN chmod +x ./scripts/entrypoint.sh
6070
COPY --chown=node:node .configs/tsconfig.base.json .configs/tsconfig.base.json
6171
COPY --chown=node:node scripts/updateVersion.ts scripts/updateVersion.ts
6272
RUN pnpm run generate
63-
RUN pnpm run build --filter=webapp...
73+
RUN --mount=type=secret,id=sentry_auth_token \
74+
SENTRY_AUTH_TOKEN=$(cat /run/secrets/sentry_auth_token) \
75+
pnpm run build --filter=webapp...
6476

6577
# Runner
6678
FROM ${NODE_IMAGE} AS runner

pnpm-lock.yaml

Lines changed: 31 additions & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)