-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spotlight): Add self-contained spotlight binary creation (#559)
This PR adds a new release type which is a self-contained CLI akin to running `npx @spotlightjs/spotlight` but without any `node` or `npx` or any other requirements on the system. It also changes how we serve the static assets: instead of serving the entire folder, which can be dangerous as it allows access to arbitrary files, we now use the `manifest.json` generated when compiling it and only serve files listed there, directly from memory. This should also increase the performance.
- Loading branch information
Showing
14 changed files
with
417 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@spotlightjs/spotlight': minor | ||
'@spotlightjs/sidecar': minor | ||
--- | ||
|
||
Create a self-contained executable for Linux, macOS, and Windows for Spotlight. | ||
Docker images now use these binaries instead of a Node build in the image. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,17 @@ jobs: | |
runs-on: ubuntu-latest | ||
# For whatever reason, yaml does not like the full "meta(changelog): Update package versions" string | ||
# So we check this in two parts | ||
if: | | ||
(contains(github.event.head_commit.message, 'meta(changelog)') | ||
&& contains(github.event.head_commit.message, 'Update package versions')) | ||
|| inputs.npm | ||
if: >- | ||
( | ||
contains(github.event.head_commit.message, 'meta(changelog)') | ||
&& | ||
contains(github.event.head_commit.message, 'Update package versions') | ||
) || inputs.npm | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
|
@@ -57,6 +61,28 @@ jobs: | |
publish: pnpm changeset:publish | ||
createGithubReleases: true | ||
|
||
- name: Store standalone spotlight binary | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: spotlight | ||
if-no-files-found: error | ||
path: packages/spotlight/dist/spotlight-* | ||
|
||
- name: Gets latest created release info | ||
id: latest_release_info | ||
uses: gregziegan/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload binaries to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file_glob: true | ||
file: packages/spotlight/dist/spotlight-* | ||
tag: ${{ steps.latest_release_info.outputs.tag_name }} | ||
make_latest: false | ||
|
||
docker: | ||
name: Docker Image | ||
needs: npm | ||
|
@@ -66,31 +92,20 @@ jobs: | |
&& (inputs.docker || github.event_name == 'push') | ||
&& (needs.npm.result == 'success' || needs.npm.result == 'skipped') | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: docker/setup-qemu-action@v3 | ||
|
||
- uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and Push Docker Image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
cache-from: type=gha,scope=prod | ||
no-cache: ${{ inputs.nocache == true }} | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
ghcr.io/getsentry/spotlight:latest | ||
ghcr.io/getsentry/spotlight:${{ github.sha }} | ||
- name: Push Docker Image as latest | ||
run: >- | ||
docker buildx imagetools create | ||
--tag ghcr.io/getsentry/spotlight:latest | ||
ghcr.io/getsentry/spotlight:${{ github.sha }} | ||
- name: Summarize | ||
run: | | ||
|
@@ -104,14 +119,12 @@ jobs: | |
!cancelled() | ||
&& (inputs.electron || github.event_name == 'push') | ||
&& (needs.npm.result == 'success' || needs.npm.result == 'skipped') | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# platform: [x64, arm64] | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"cSpell.words": [ | ||
"APPLEID", | ||
"APPLEIDPASS", | ||
"Astro", | ||
"Astro's", | ||
"astrojs", | ||
"codesign", | ||
"contextlines", | ||
"Endcaps", | ||
"fontsource", | ||
"getsentry", | ||
"iife", | ||
"nextjs", | ||
"notarytool", | ||
"outro", | ||
"pageload", | ||
"postject", | ||
"spotlightjs", | ||
"svgr", | ||
"tailwindcss", | ||
"TEAMID", | ||
"treeshake", | ||
"ttfb", | ||
"unsign", | ||
"uuidv", | ||
"webvitals" | ||
"webvitals", | ||
"xcrun" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,6 @@ | ||
FROM node:lts-bullseye-slim AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
FROM base AS build | ||
FROM debian:bookworm-slim | ||
ARG TARGETARCH | ||
WORKDIR /app | ||
COPY . /app | ||
# https://github.com/pnpm/pnpm/issues/6295 | ||
RUN echo "dedupe-peer-dependents=false" > .npmrc | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
RUN pnpm run --filter="./packages/sidecar" build && \ | ||
pnpm run --filter="./packages/overlay" build | ||
RUN pnpm run --filter="./packages/spotlight" build | ||
RUN pnpm deploy --filter="./packages/spotlight" --prod /deploy/spotlight | ||
COPY --chmod=555 packages/spotlight/dist/spotlight-linux-$TARGETARCH /app/spotlight | ||
|
||
FROM base as spotlight | ||
# FROM gcr.io/distroless/nodejs20-debian12 as sidecar | ||
COPY --from=build /deploy/spotlight /app | ||
WORKDIR /app | ||
EXPOSE 8969 | ||
ENTRYPOINT [ "./bin/run.js" ] | ||
ENTRYPOINT ["/app/spotlight"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ | |
}, | ||
"packageManager": "[email protected]", | ||
"volta": { | ||
"node": "20.10.0", | ||
"node": "22.11.0", | ||
"pnpm": "9.13.0" | ||
} | ||
} |
Oops, something went wrong.