diff --git a/.github/workflows/check-schema.yml b/.github/workflows/check-schema.yml new file mode 100644 index 0000000000..51baeec0b3 --- /dev/null +++ b/.github/workflows/check-schema.yml @@ -0,0 +1,27 @@ +name: Check Config Schema + +on: + pull_request: + +jobs: + check-schema: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: '20' + + - name: Install dependencies + run: npm ci + + - name: Generate JSON Schema from config.d.ts + run: npm run generate-schema + + - name: Check for changes + run: | + git diff --exit-code config.schema.json diff --git a/.prettierignore b/.prettierignore index ee2d74488d..4dd75fd452 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,3 +5,4 @@ node_modules /src/assets/emoji_altname_table.json /src/assets/unicode_emojis.json /public/new-relic.js +*.schema.json diff --git a/README.md b/README.md index f5c8248ac3..866fb79e78 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,25 @@ traQ allows ease communication among team members by organizing contexts into tr ## Deployment +### Using Docker + +When deploying using Docker, you can mount `config.json` externally: + +```bash +docker run -d \ + -p 80:80 \ + -v /path/to/your/config.json:/app/override/config.json \ + traq-ui:latest +``` + +See [`config.json` in the manifest repository](https://github.com/traPtitech/manifest/blob/main/traq/frontend/config.json) for an example. +You can also mount a `config.js` file at `/app/override/config.js` instead for backward compatibility, and it will be automatically converted to `config.js` at runtime. +Please note that if both `config.js` and `config.json` are mounted, `config.js` will be ignored and overwritten by the mapped `config.json`. + +Refer to [`config.d.ts`](./config.d.ts) for the TypeScript type definition and [`config.schema.json`](./config.schema.json) for the JSON Schema. + +### Other Deployment Methods + If you want to deploy your own instance of traQ, then follow the instructions in backend [deployment.md](https://github.com/traPtitech/traQ/blob/master/docs/deployment.md). ## Development diff --git a/build/docker/startup.sh b/build/docker/startup.sh index 00dd119d98..a20f511938 100644 --- a/build/docker/startup.sh +++ b/build/docker/startup.sh @@ -14,8 +14,24 @@ echo "Startup: check override files" ls /app/override/* >/dev/null 2>&1 if [ $? -eq 0 ]; then - echo "Startup: copy override files" - cp -r -L /app/override/* /usr/share/caddy + echo "Startup: copy override files" + cp -r -L /app/override/* /usr/share/caddy +fi + +### +# config.jsonからconfig.jsへの変換 +### +if [ -f /app/override/config.json ]; then + if [ -f /app/override/config.js ]; then + echo "WARNING: Both config.json and config.js are mounted at /app/override/" + echo "WARNING: config.js will be ignored and overwritten by the mapped config.json" + fi + echo "Startup: converting config.json to config.js" + { + echo ";(() => { self.traQConfig = " + cat /app/override/config.json + echo " })()" + } > /usr/share/caddy/config.js fi ### @@ -35,17 +51,17 @@ sed -i -e "s/#0D67EA/$THEME_COLOR/g" /usr/share/caddy/index.html # New Relic 設定 ### if [ -n "$NEW_RELIC_LICENSE_KEY" ] && [ -n "$NEW_RELIC_ACCOUNT_ID" ] && [ -n "$NEW_RELIC_TRUST_KEY" ] && [ -n "$NEW_RELIC_AGENT_ID" ] && [ -n "$NEW_RELIC_APPLICATION_ID" ]; then - echo "Startup: set up New Relic" - sed -i -e "s/LICENSE_KEY_PLACEHOLDER/$NEW_RELIC_LICENSE_KEY/g" /usr/share/caddy/new-relic.js - sed -i -e "s/ACCOUNT_ID_PLACEHOLDER/$NEW_RELIC_ACCOUNT_ID/g" /usr/share/caddy/new-relic.js - sed -i -e "s/TRUST_KEY_PLACEHOLDER/$NEW_RELIC_TRUST_KEY/g" /usr/share/caddy/new-relic.js - sed -i -e "s/AGENT_ID_PLACEHOLDER/$NEW_RELIC_AGENT_ID/g" /usr/share/caddy/new-relic.js - sed -i -e "s/APPLICATION_ID_PLACEHOLDER/$NEW_RELIC_APPLICATION_ID/g" /usr/share/caddy/new-relic.js - CACHE_KEY=$(md5sum /usr/share/caddy/new-relic.js | cut -d ' ' -f 1) - mv /usr/share/caddy/new-relic.js /usr/share/caddy/new-relic-$CACHE_KEY.js - sed -i -e "s//