Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ ENV TRACKER_API_BASE=$TRACKER_API_BASE
ENV NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL
ENV NEXT_PUBLIC_POSTHOG_TOKEN=$NEXT_PUBLIC_POSTHOG_TOKEN

RUN pnpm run build
# PostHog source map upload configuration. The project ID is not sensitive and
# can be passed as a build argument. Pass POSTHOG_API_KEY as a BuildKit secret
# so it is not persisted in the image history or build cache.
ARG POSTHOG_PROJECT_ID
ENV POSTHOG_PROJECT_ID=$POSTHOG_PROJECT_ID

RUN --mount=type=secret,id=POSTHOG_API_KEY \
if [ -f /run/secrets/POSTHOG_API_KEY ]; then \
export POSTHOG_API_KEY="$(cat /run/secrets/POSTHOG_API_KEY)"; \
fi; \
pnpm run build

FROM base AS runner
WORKDIR /app
Expand Down
15 changes: 14 additions & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { withPostHogConfig } from "@posthog/nextjs-config";
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
Expand Down Expand Up @@ -164,4 +165,16 @@ const nextConfig: NextConfig = {
},
};

export default nextConfig;
const posthogApiKey = process.env.POSTHOG_API_KEY;
const posthogProjectId = process.env.POSTHOG_PROJECT_ID;

export default withPostHogConfig(nextConfig, {
personalApiKey: posthogApiKey ?? "",
projectId: posthogProjectId,
sourcemaps: {
// Keep builds working in local development and deployments where source
// map upload credentials have not been configured yet.
enabled: Boolean(posthogApiKey && posthogProjectId),
deleteAfterUpload: true,
},
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@buildcanada/colours": "^0.3.3",
"@buildcanada/components": "^0.3.5",
"@cloudflare/stream-react": "^1.9.3",
"@posthog/nextjs-config": "^1.9.68",
"@radix-ui/react-checkbox": "^1.3.3",
"@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-select": "^2.2.5",
Expand Down
Loading
Loading