-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Docker Compose crashes when using @sentry/nextjs #9405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, since this might have to do with some dependencies clashing in your lockfile, would you mind providing a small repro repo we can clone to effectively debug this? Thanks. As a workaround in the meanwhile you could set:
in you next.config.js. Note that this will prevent source maps from being uploaded. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Have you fixed this issue yet? Running into the same issue. |
The issue still happens. My workaround was using this node image |
I FIGURED IT OUT.You have to add the ca-certificates package from apt to the ubuntu instance. Jetbrains AI to the rescue when I asked it the following: Question
It responsed with: AnswerBased on the error message you provided, it appears your Docker image is experiencing problems authenticating the SSL certificate for Sentry during the build process. This is commonly because it can't verify the SSL certificate's issuer. Here are a few things you can check and attempt to solve this:
Remember, changes in Dockerfile would require you to rebuild your image. Final DockerfileFROM node:21-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
RUN apt-get update -y
RUN apt-get install -y ca-certificates
FROM base AS build
WORKDIR /app
ARG NPM_TOKEN
RUN echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# Write to .env
ARG NEXT_PUBLIC_API_URL="http://127.0.0.1:5000/tracking"
RUN echo "NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}" >> .env
ARG NEXT_OUTPUT="standalone"
RUN echo "NEXT_OUTPUT=${NEXT_OUTPUT}" >> .env
ARG SENTRY_AUTH_TOKEN
RUN echo "SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}" >> .env
# Disable telemetry during build time
ENV NEXT_TELEMETRY_DISABLED 1
RUN npm run build
FROM base
WORKDIR /app
COPY --from=build /app/node_modules /app/node_modules
# Disable telemetry during runtime
ENV NEXT_TELEMETRY_DISABLED 1
# Add nextjs user and group
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=build --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"] Final docker-compose.ymlversion: "3"
services:
nextjs:
container_name: next-app
build:
dockerfile: ./Dockerfile
context: .
args:
- NPM_TOKEN=
- NEXT_PUBLIC_API_URL=
- SENTRY_AUTH_TOKEN=
ports:
- 3000:3000 |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
^7.74.1
Framework Version
Next.js 13.5.5, React: 18.2.0
Link to Sentry event
No response
SDK Setup
sentry config:
`/ This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: "https://f24c7de63b0064121f43c8c8c83dc047@o4506087957921792.ingest.sentry.io/4506087959429120",
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
replaysOnErrorSampleRate: 1.0,
// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,
// You can remove this option if you're not planning to use the Sentry Session Replay feature:
integrations: [
new Sentry.Replay({
// Additional Replay configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
],
});
`
Steps to Reproduce
Module not found: Can't resolve '@sentry/utils/esm/buildPolyfills'
,@sentry/utils
Sentry CLI Plugin: Command failed: /dility/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sentry/cli/sentry-cli releases new qocVBIgiVuEmOR8MUS5Ey 16.79 /dility/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sentry/cli/sentry-cli: 2: Syntax error: "(" unexpected
RUN pnpm add @sentry/cli
in Dockerfile to see if that works but it throws the same error.Dockerfile and docker compose files:
`FROM node:latest
WORKDIR /dility
COPY package.json pnpm-lock.yaml /dility/
RUN npm install -g pnpm
&& pnpm install
RUN pnpm add @sentry/utils
RUN pnpm add @sentry/cli
COPY . .
RUN pnpm run build
EXPOSE 3000
CMD ["pnpm", "start"]
`
version: '3' services: app: build: context: . dockerfile: Dockerfile ports: - '3000:3000' volumes: - .:/dility environment: - NODE_ENV=production
Expected Result
Getting my app deployed
Actual Result
My app is crashing with this error:
Sentry CLI Plugin: Command failed: /dility/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sentry/cli/sentry-cli releases new qocVBIgiVuEmOR8MUS5Ey 16.79 /dility/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sentry/cli/sentry-cli: 2: Syntax error: "(" unexpected
The text was updated successfully, but these errors were encountered: