sentry intergration & upload source map (#4311)

This commit is contained in:
dungphampt
2026-02-06 23:11:17 +07:00
committed by GitHub
parent 2001ed158f
commit a91cd8f86f
4 changed files with 166 additions and 17 deletions
+36 -14
View File
@@ -1,26 +1,48 @@
ARG FLUTTER_VERSION=3.32.8
# Stage 1 - Install dependencies and build the app
# This matches the flutter version on our CI/CD pipeline on Github
FROM --platform=amd64 ghcr.io/instrumentisto/flutter:${FLUTTER_VERSION} AS build-env
# Set directory to Copy App
WORKDIR /app
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_ORG
ARG SENTRY_PROJECT
ARG SENTRY_URL
ARG SENTRY_RELEASE
ARG VCS_REF
ARG GITHUB_SHA
WORKDIR /app
COPY . .
# Precompile tmail flutter
RUN ./scripts/prebuild.sh
# Build flutter for web
RUN flutter build web --release --source-maps
ENV GITHUB_SHA=$GITHUB_SHA \
SENTRY_ORG=$SENTRY_ORG \
SENTRY_PROJECT=$SENTRY_PROJECT \
SENTRY_URL=$SENTRY_URL \
SENTRY_RELEASE=$SENTRY_RELEASE
RUN ./scripts/prebuild.sh && \
flutter build web --release --source-maps --dart-define=SENTRY_RELEASE=$SENTRY_RELEASE && \
if [ -n "$SENTRY_AUTH_TOKEN" ] && [ -n "$SENTRY_ORG" ] && [ -n "$SENTRY_PROJECT" ] && [ -n "$SENTRY_RELEASE" ]; then \
echo "Sentry configuration detected, uploading sourcemaps..." && \
curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=2.20.7 bash && \
sentry-cli releases new "$SENTRY_RELEASE" && \
sentry-cli sourcemaps upload build/web \
--org "$SENTRY_ORG" \
--project "$SENTRY_PROJECT" \
--auth-token "$SENTRY_AUTH_TOKEN" \
--release "$SENTRY_RELEASE" \
--dist "$GITHUB_SHA" \
--url-prefix "~/" \
--validate \
--wait && \
sentry-cli releases finalize "$SENTRY_RELEASE" && \
echo "Sentry sourcemaps uploaded successfully"; \
else \
echo "Sentry configuration not complete, skipping sourcemap upload"; \
fi
# Stage 2 - Create the run-time image
FROM nginx:alpine
RUN apk add gzip
COPY --from=build-env /app/server/nginx.conf /etc/nginx
COPY --from=build-env /app/build/web /usr/share/nginx/html
# Record the exposed port
EXPOSE 80
# Before stating NGinx, re-zip all the content to ensure customizations are propagated
CMD gzip -k -r -f /usr/share/nginx/html/ && nginx -g 'daemon off;'
CMD gzip -k -r -f /usr/share/nginx/html/ && nginx -g 'daemon off;'