-
Notifications
You must be signed in to change notification settings - Fork 6
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
Un-ossify the build system #36
Changes from all commits
d0fb3dd
a7233d8
43c1d7f
f7b651f
a22b4b7
768243a
5a6b5ca
1e80dd6
2ed9327
922b119
9a6f2d1
3de0ff8
84b0e64
c36ff77
23d4398
cf93156
7d93352
696402a
cfcffdc
8178d79
fbfb7b6
81d9f88
f49c665
605ce2f
f298863
5c889f6
c8dbe00
5fb0109
f042762
6764286
3a35231
b2723b4
54caa5d
bbae2ee
91aaef1
f68c0a1
83cf1c4
54ddf27
1e1dc14
df9d933
555e347
3ea9ba5
a8fb449
72d8d30
0ac22b1
5dab8d2
19e6956
9345420
0c0748f
eae1f45
f40dfab
d4a4469
65ef89a
a257dad
b123401
83e7fec
8f8b487
b3942fa
09897ce
50946c8
d158114
9e331c3
ebda000
feb5a66
1e37c88
3a950ac
4139993
31c7435
3f84528
6c9164b
7aaaba2
255093f
2a6c791
17c040e
267b050
a819f81
4c6fec0
f29c50a
07fc5ca
03bee8d
35c63f5
e4b8788
2ff00bc
61e35fd
f87a667
c8d43d3
5b47c03
40fc6df
0434020
d3f9af2
307b604
09179f4
d733e60
00ddc22
f1c4a69
cac3938
195df0f
efe889d
2af936a
160ac78
93ddd1b
f021eb0
4ced366
8181f8b
a45c399
ba66ccd
81fd01d
5ece1d4
339b7e7
2e586cb
f7a4a8d
734f1f5
5c9bb09
42431a3
3b255db
c9982e2
8cee8d5
a091e5c
cb2403d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
yarn-debug.log | ||
yarn-error.log | ||
spicedb | ||
zed | ||
build | ||
.vercel |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ spicedb | |
zed | ||
build | ||
.vercel | ||
.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
ARG BASE_IMAGE=node:18-alpine3.18 | ||
ARG BASE_IMAGE=node:22-alpine | ||
|
||
FROM --platform=$BUILDPLATFORM $BASE_IMAGE AS playground-builder | ||
WORKDIR /app | ||
COPY ./package.json . | ||
COPY ./yarn.lock . | ||
COPY ./playground-ui ./playground-ui | ||
COPY ./spicedb-common ./spicedb-common | ||
COPY ./playground/package.json ./playground/package.json | ||
# Bring in everything not ignored by the dockerignore | ||
COPY . . | ||
Comment on lines
-5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need to be specific when we have dockerignore |
||
ENV YARN_CACHE_FOLDER=/tmp/yarn_cache | ||
RUN yarn install --frozen-lockfile --production --non-interactive --network-timeout 1000000 | ||
|
||
COPY ./playground ./playground | ||
# Environment variables for build time. | ||
ARG VITE_AUTHZED_DEVELOPER_GATEWAY_ENDPOINT="" | ||
ARG VITE_GOOGLE_ANALYTICS_MEASUREMENT_ID="" | ||
|
||
WORKDIR /app/playground | ||
ARG VITE_DISCORD_CHANNEL_ID="" | ||
ARG VITE_DISCORD_INVITE_URL="https://authzed.com/discord" | ||
ARG VITE_DISCORD_SERVER_ID="" | ||
|
||
RUN yarn install --frozen-lockfile --non-interactive --network-timeout 1000000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We explicitly want dev dependencies in the build process - otherwise we're leaving out things like typescript and our bundler. |
||
|
||
ARG APPLICATION_ROOT=/ | ||
ARG NODE_OPTIONS=--openssl-legacy-provider | ||
ENV PUBLIC_URL ${APPLICATION_ROOT} | ||
RUN yarn build | ||
|
||
FROM $BASE_IMAGE AS playground-verifier | ||
RUN npm install -g jshint | ||
COPY ./playground/contrib/generate-config-env.sh . | ||
COPY ./playground/contrib/test-config-env.sh . | ||
RUN ./test-config-env.sh | ||
RUN echo 'Config Verified' > verified | ||
Comment on lines
-23
to
-27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Config isn't used anymore. |
||
|
||
FROM nginx:1.25.2 | ||
LABEL maintainer="AuthZed <[email protected]>" | ||
|
@@ -34,18 +28,14 @@ ENV PORT=3000 | |
ENTRYPOINT ["./docker-entrypoint-wrapper.sh"] | ||
CMD [] | ||
|
||
COPY ./playground/contrib/generate-config-env.sh . | ||
COPY ./playground/contrib/test-nginx-conf.sh . | ||
COPY ./playground/contrib/test-config-env.sh . | ||
COPY ./playground/contrib/nginx.conf.tmpl . | ||
COPY ./playground/contrib/docker-entrypoint-wrapper.sh . | ||
COPY ./contrib/generate-config-env.sh . | ||
COPY ./contrib/test-nginx-conf.sh . | ||
COPY ./contrib/test-config-env.sh . | ||
COPY ./contrib/nginx.conf.tmpl . | ||
COPY ./contrib/docker-entrypoint-wrapper.sh . | ||
RUN bash ./test-nginx-conf.sh | ||
|
||
COPY --from=playground-verifier verified . | ||
COPY --from=playground-builder /app/playground/build/ /usr/share/nginx/html/ | ||
COPY wasm/main.wasm /usr/share/nginx/html/static/main.wasm | ||
COPY wasm/zed.wasm /usr/share/nginx/html/static/zed.wasm | ||
Comment on lines
-44
to
-47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of this is taken care of by the build process now. |
||
COPY --from=playground-builder /app/build/ /usr/share/nginx/html/ | ||
|
||
RUN mkdir /usr/share/nginx/html/static/schemas | ||
COPY examples/schemas/ /usr/share/nginx/html/static/schemas | ||
RUN ls /usr/share/nginx/html/static/schemas > /usr/share/nginx/html/static/schemas/_all |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- [x] Fix tests | ||
- [x] Fix environment variable setting in dockerfile | ||
- [ ] Fix environment variable setting in vercel | ||
- [x] Fix build | ||
- [x] Fix buf.gen.yaml | ||
- [x] Get local instance working without errors | ||
- [ ] Add documentation of `buf generate` |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This configuration automatically generates all of the code that we need for both spicedb and the authzed API. Part of the reason for collapsing these is that the previous grpc-web generated code had imports in it but not exports, and vite and typescript didn't like that, because they're ESM-aware bundlers rather than doing things the way webpack did where it just dragged everything into a common namespace. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
version: 'v2' | ||
plugins: | ||
- remote: "buf.build/community/timostamm-protobuf-ts:v2.9.1" | ||
out: 'src/spicedb-common/protodefs' | ||
opt: | ||
- "long_type_string" | ||
- "generate_dependencies" | ||
- "optimize_code_size" | ||
inputs: | ||
- module: "buf.build/authzed/api:v1.38.0" | ||
paths: | ||
- "authzed/api/v0" | ||
- git_repo: "https://github.com/authzed/spicedb" | ||
subdir: "proto/internal" | ||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note too that we're only generating the code necessary for this project - we're not bringing in every proto file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
generate_nginx() { | ||
conf_template=$1 | ||
nginx_conf=$2 | ||
envsubst '$PLAYGROUND_DEVELOPER_API_DOWNLOAD_ENDPOINT,$HEADER_CONTENT_SECURITY_POLICY' < "$conf_template" > "$nginx_conf" | ||
echo "${nginx_conf}:" | ||
cat "$nginx_conf" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,6 @@ http { | |
add_header Cache-Control no-cache; | ||
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always; | ||
} | ||
location /config.json { | ||
add_header Cache-Control no-cache; | ||
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always; | ||
} | ||
location /config-env.js { | ||
add_header Cache-Control no-cache; | ||
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always; | ||
} | ||
Comment on lines
-33
to
-40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These files were used to provide env-specific configuration. They'd be necessary if playground was built once and deployed many places, but our deployment of playground has changed, and it's now built for each deployment. This means that we can take advantage of env-based configuration at build time rather than needing to manage files that reflect the configuration. You'll see similar changes in several places. |
||
location ~ ^/s/([^/]+)/download$ { | ||
rewrite ^/s/([^/]+)/download$ ${PLAYGROUND_DEVELOPER_API_DOWNLOAD_ENDPOINT}/$1; | ||
add_header Content-Security-Policy "frame-ancestors 'self' ${HEADER_CONTENT_SECURITY_POLICY};" always; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import js from '@eslint/js' | ||
import globals from 'globals' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import reactRefresh from 'eslint-plugin-react-refresh' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default tseslint.config( | ||
{ ignores: ['dist'] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
ecmaVersion: 2020, | ||
globals: globals.browser, | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
'react-refresh': reactRefresh, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
}, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,23 +5,23 @@ | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"></script> | ||
<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css" rel="stylesheet" type="text/css" /> | ||
|
||
<script src="%PUBLIC_URL%/wasm_exec.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no reason for these not to be root-relative. |
||
<script src="/wasm_exec.js"></script> | ||
|
||
<meta charset="utf-8" /> | ||
<meta name="robots" content="noindex,nofollow" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.svg" /> | ||
<link rel="icon" href="/favicon.svg" /> | ||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<script src="%PUBLIC_URL%/config-env.js"></script> | ||
<link rel="apple-touch-icon" href="/logo192.png" /> | ||
<link rel="manifest" href="/manifest.json" /> | ||
<title>SpiceDB Playground</title> | ||
</head> | ||
|
||
<body> | ||
<noscript>JavaScript is required to run this single-page app. Sorry :/</noscript> | ||
<div id="root"></div> | ||
<div id="portal"></div> | ||
<script type="module" src="/src/index.tsx"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what vite uses as its entrypoint, which is slightly different from how webpack used to do it. |
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,111 @@ | ||
{ | ||
"name": "code", | ||
"private": "true", | ||
"name": "playground", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"private": true, | ||
"dependencies": { | ||
"@apollo/client": "^3.7.3", | ||
"@apollo/link-context": "^2.0.0-beta.3", | ||
"@fontsource/roboto": "^5.1.1", | ||
"@fortawesome/fontawesome-svg-core": "^6.4.0", | ||
"@fortawesome/free-solid-svg-icons": "^6.2.1", | ||
"@fortawesome/react-fontawesome": "^0.2.0", | ||
"@glideapps/glide-data-grid": "^4.0.2", | ||
"@glideapps/glide-data-grid-cells": "^4.0.2", | ||
"@material-ui/core": "^4.12.4", | ||
"@material-ui/icons": "^4.11.3", | ||
"@material-ui/lab": "^4.0.0-alpha.61", | ||
"@monaco-editor/react": "^4.3.1", | ||
"@protobuf-ts/grpcweb-transport": "^2.9.4", | ||
"@protobuf-ts/plugin": "^2.6.0", | ||
"ansi-to-html": "^0.7.2", | ||
"color-hash": "^2.0.2", | ||
"d3-scale-chromatic": "^2.0.0", | ||
"dequal": "^2.0.2", | ||
"file-saver": "^2.0.5", | ||
"file-select-dialog": "^1.5.4", | ||
"google-protobuf": "^3.21.2", | ||
"graphql": "16.6.0", | ||
"install": "^0.13.0", | ||
"line-column": "^1.0.2", | ||
"lodash.throttle": "^4.1.1", | ||
"markdown-it": "^13.0.1", | ||
"marked": "^4.0.10", | ||
"monaco-editor-core": "^0.39.0", | ||
"parsimmon": "^1.18.1", | ||
"react": "^18.3.1", | ||
"react-cookie": "^4.1.1", | ||
"react-dom": "^18.3.1", | ||
"react-joyride": "^2.5.3", | ||
"react-reflex": "^4.0.9", | ||
"react-responsive-carousel": "^3.2.23", | ||
"react-router-dom": "^5.3.4", | ||
"sjcl": "^1.0.8", | ||
"string-to-color": "^2.2.2", | ||
"string.prototype.replaceall": "^1.0.6", | ||
"styled-components": "^6.1.14", | ||
"typeface-roboto-mono": "^1.1.13", | ||
"use-deep-compare": "^1.1.0", | ||
"use-deep-compare-effect": "^1.8.1", | ||
"use-keyboard-shortcuts": "^2.2.2", | ||
"visjs-network": "^4.24.11", | ||
"yaml": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.18.0", | ||
"@testing-library/react": "^14.0.0", | ||
"@testing-library/user-event": "^14.4.3", | ||
"@types/color-hash": "^1.0.2", | ||
"@types/d3-scale-chromatic": "^3.0.0", | ||
"@types/file-saver": "^2.0.5", | ||
"@types/jest": "^29.5.0", | ||
"@types/line-column": "^1.0.0", | ||
"@types/markdown-it": "^12.2.3", | ||
"@types/node": "^20.3.3", | ||
"@types/parsimmon": "^1.10.6", | ||
"@types/react": "^18.3.1", | ||
"@types/react-copy-to-clipboard": "^5.0.4", | ||
"@types/react-dom": "^18.3.1", | ||
"@types/react-router-dom": "^5.3.0", | ||
"@types/sjcl": "^1.0.30", | ||
"@types/styled-components": "^5.1.26", | ||
"@types/use-deep-compare-effect": "^1.5.1", | ||
"@types/uuid": "^9.0.1", | ||
"@vitejs/plugin-react": "^4.3.4", | ||
"cypress": "^12.9.0", | ||
"cypress-wait-until": "^1.7.2", | ||
"eslint": "^9.18.0", | ||
"eslint-plugin-react-hooks": "^5.1.0", | ||
"eslint-plugin-react-refresh": "^0.4.18", | ||
"globals": "^15.14.0", | ||
"postcss-safe-parser": "7.0.0", | ||
"typescript": "~5.7.3", | ||
"typescript-eslint": "^8.20.0", | ||
"vite": "^6.0.7", | ||
"vite-plugin-svgr": "^4.3.0", | ||
"vitest": "^2.1.8" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "yarn workspace playground build && ./scripts/copy-build.sh", | ||
"dev": "HTTPS=true vite", | ||
"build": "tsc -b && vite build && ./scripts/copy-build.sh", | ||
"test": "vitest", | ||
"lint": "eslint .", | ||
"lint-fix": "eslint --fix .", | ||
"cy:run": "cypress run --browser chrome", | ||
"cy:open": "cypress open", | ||
"update:spicedb": "./scripts/update-spicedb.sh", | ||
"update:zed": "./scripts/update-zed.sh" | ||
}, | ||
"workspaces": [ | ||
"spicedb-common", | ||
"playground-ui", | ||
"playground" | ||
], | ||
"dependencies": {} | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# You can copy this file to .env and set these locally. | ||
# Otherwise we set envs at the vercel level. | ||
VITE_AUTHZED_DEVELOPER_GATEWAY_ENDPOINT= | ||
VITE_GOOGLE_ANALYTICS_MEASUREMENT_ID= | ||
|
||
VITE_DISCORD_CHANNEL_ID= | ||
VITE_DISCORD_INVITE_URL=https://authzed.com/discord | ||
VITE_DISCORD_SERVER_ID= |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get to the most recent LTS