Disable Sentry inside Docker (#1781)

This commit is contained in:
Kostas Bariotis 2020-06-18 12:18:57 +01:00 committed by GitHub
parent f1ceeab8d9
commit 8f65e37dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -17,12 +17,10 @@ COPY . .
FROM node:14-alpine AS build FROM node:14-alpine AS build
ARG NODE_ENV=production ARG NODE_ENV=production
ARG REACT_APP_INCLUDE_GTAG=false
WORKDIR /opt/node_app WORKDIR /opt/node_app
COPY --from=deps /opt/node_app . COPY --from=deps /opt/node_app .
RUN ls RUN npm run build:app:docker
RUN npm run build:app
FROM nginx:1.17-alpine FROM nginx:1.17-alpine

View File

@ -75,6 +75,7 @@
"build": "npm run build:app && npm run build:zip", "build": "npm run build:app && npm run build:zip",
"build-node": "node ./scripts/build-node.js", "build-node": "node ./scripts/build-node.js",
"build:app": "REACT_APP_INCLUDE_GTAG=true REACT_APP_GIT_SHA=$NOW_GITHUB_COMMIT_SHA react-scripts build", "build:app": "REACT_APP_INCLUDE_GTAG=true REACT_APP_GIT_SHA=$NOW_GITHUB_COMMIT_SHA react-scripts build",
"build:app:docker": "REACT_APP_INCLUDE_GTAG=false REACT_APP_DISABLE_SENTRY=true react-scripts build",
"build:zip": "node ./scripts/build-version.js", "build:zip": "node ./scripts/build-version.js",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"fix": "npm run fix:other && npm run fix:code", "fix": "npm run fix:other && npm run fix:code",

View File

@ -27,12 +27,14 @@ const SentryEnvHostnameMap: { [key: string]: string } = {
"now.sh": "staging", "now.sh": "staging",
}; };
const onlineEnv = Object.keys(SentryEnvHostnameMap).find( // Disable Sentry locally or inside the Docker to avoid noise/respect privacy
const onlineEnv =
process.env.REACT_APP_DISABLE_SENTRY !== "true" &&
Object.keys(SentryEnvHostnameMap).find(
(item) => window.location.hostname.indexOf(item) >= 0, (item) => window.location.hostname.indexOf(item) >= 0,
); );
Sentry.init({ Sentry.init({
// Disable Sentry locally to avoid noise
dsn: onlineEnv dsn: onlineEnv
? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260" ? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260"
: undefined, : undefined,