diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..30b467e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules/ +coverage/ +build/ diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..c45acb7 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,70 @@ +name: build + +on: [push] + +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: cache node modules + uses: actions/cache@v2 + id: yarn-cache + with: + path: node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: yarn install + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install + - name: yarn netlify-sass + run: yarn netlify-sass + - name: yarn build + run: yarn build + - name: run tests + run: yarn test-ci + - name: run puppeteer tests + run: yarn test-puppeteer-build + docker: + runs-on: ubuntu-20.04 + needs: test + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v2 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: login to container registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: get tags + shell: bash + run: echo "##[set-output name=tags;]ghcr.io/commaai/cabana:$(echo ${GITHUB_REF#refs/heads/})$(if [ ${GITHUB_REF} = refs/heads/master ] ; then echo ,ghcr.io/commaai/cabana:latest; fi;)" + id: extract_tags + - name: Build and push + uses: docker/build-push-action@v2 + with: + build-args: SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} + builder: ${{ steps.buildx.outputs.name }} + context: . + push: true + tags: ${{ steps.extract_tags.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6cc7114..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: node_js -sudo: required - -# install azure-cli 2.0, which is the preferred version. Switch to use this -# after azure accounts are handled. -before_install: - - echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | sudo tee /etc/apt/sources.list.d/azure-cli.list - - sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893 - - sudo apt-get install apt-transport-https - - sudo apt-get update && sudo apt-get install azure-cli libudev-dev --allow-unauthenticated -# - yarn global add azure-cli@0.10.x - -before_script: yarn netlify-sass - -script: - - yarn test - - yarn build - -deploy: - provider: script - script: scripts/travis-deploy.sh - skip_cleanup: true - on: - branch: master - tags: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..16b0dcd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:10.24-buster + +RUN apt-get update && apt-get install -y libusb-dev libudev-dev && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY package.json yarn.lock /app/ +RUN yarn install --frozen-lockfile + +COPY . /app/ +ARG SENTRY_AUTH_TOKEN +RUN yarn netlify-sass +RUN yarn build + + +FROM nginx:1.21 + +COPY config.js.template /etc/nginx/templates/config.js.template +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=0 /app/build /usr/share/nginx/html + +ENV NGINX_ENVSUBST_OUTPUT_DIR /usr/share/nginx/html diff --git a/README.md b/README.md index 17932cf..b8eda9c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Cabana - + ## Setup diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index d31fb69..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,21 +0,0 @@ - -trigger: -- master - -pr: -- master - -pool: - vmImage: 'ubuntu-latest' - -steps: -- task: NodeTool@0 - inputs: - versionSpec: '10.x' - displayName: 'Install Node.js' - -- script: | - npm install yarn - yarn - yarn run test-ci - displayName: 'yarn test' diff --git a/config.js.template b/config.js.template new file mode 100644 index 0000000..48e866a --- /dev/null +++ b/config.js.template @@ -0,0 +1,4 @@ +window.COMMA_URL_ROOT = '${COMMA_URL_ROOT}'; +window.ATHENA_URL_ROOT = '${ATHENA_URL_ROOT}'; +window.USERADMIN_URL_ROOT = '${USERADMIN_URL_ROOT}'; +window.SENTRY_ENV = '${SENTRY_ENV}'; diff --git a/craco.config.js b/craco.config.js index e70313e..51abb93 100644 --- a/craco.config.js +++ b/craco.config.js @@ -8,7 +8,7 @@ module.exports = function ({ env }) { plugin: WorkerLoaderPlugin } ]; - if (env === 'production') { + if (process.env.NODE_ENV === 'production' && process.env.SENTRY_AUTH_TOKEN) { plugins.push({ plugin: SentryPlugin }); diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index e69de29..0000000 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..ab31c30 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,13 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + root /usr/share/nginx/html; + location / { + try_files $uri $uri/ /index.html; + } + + error_page 404 /404.html; + error_page 500 502 503 504 /50x.html; +} diff --git a/package.json b/package.json index aac1991..daa735e 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,12 @@ "name": "can-explorer", "version": "0.4.2", "private": true, - "homepage": "https://community.comma.ai/cabana", + "homepage": "https://cabana.comma.ai/", "dependencies": { - "@commaai/comma-api": "^1.7.0", + "@commaai/comma-api": "^2.1.2", "@commaai/hls.js": "^0.12.7", "@commaai/log_reader": "^0.5.5", - "@commaai/my-comma-auth": "^1.3.0", + "@commaai/my-comma-auth": "^1.4.1", "@commaai/pandajs": "^0.3.4", "@craco/craco": "^5.5.0", "ap": "^0.2.0", @@ -42,6 +42,7 @@ "node-sass": "^4.12.0", "prettier": "^1.9.2", "prop-types": "^15.5.10", + "query-string": "^5.0.1", "randomcolor": "^0.5.4", "raven-js": "^3.16.0", "react": "^16.2.0", @@ -62,7 +63,6 @@ "thyming": "^0.1.1", "vega": "^5.3.4", "vega-lite": "^3.0.0", - "query-string": "^5.0.1", "vega-tooltip": "^0.4.0" }, "devDependencies": { @@ -78,11 +78,11 @@ "detect-port": "1.1.0", "dotenv": "2.0.0", "env-cmd": "^8.0.2", + "expect-puppeteer": "^5.0.4", "gh-pages": "^2.1.1", "http-proxy-middleware": "0.17.3", - "json-loader": "0.5.4", - "expect-puppeteer": "^5.0.4", "jest-puppeteer": "^5.0.4", + "json-loader": "0.5.4", "puppeteer": "^9.1.0", "rimraf": "^3.0.0", "serve-handler": "^6.1.2", diff --git a/public/404.html b/public/404.html deleted file mode 100644 index 74c0029..0000000 --- a/public/404.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Single Page Apps for GitHub Pages - - - - - diff --git a/public/_redirects b/public/_redirects deleted file mode 100644 index 556272c..0000000 --- a/public/_redirects +++ /dev/null @@ -1,6 +0,0 @@ -/ /index.html 200 - -/cabana/:slug /:slug 200 -/cabana/* /:splat 200 -/cabana/:a/:b /:a/:b 200 -/cabana/:a/:b/:c /:a/:b/:c 200 diff --git a/public/config.js b/public/config.js new file mode 100644 index 0000000..c859a5f --- /dev/null +++ b/public/config.js @@ -0,0 +1,3 @@ +window.COMMA_URL_ROOT = 'https://api.comma.ai/'; +window.ATHENA_URL_ROOT = 'https://athena.comma.ai/'; +window.USERADMIN_URL_ROOT = 'https://useradmin.comma.ai/'; diff --git a/public/index.html b/public/index.html index adc4022..ae892a8 100644 --- a/public/index.html +++ b/public/index.html @@ -17,50 +17,9 @@ manifest.json provides metadata used when your web app is added to the homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ --> - - - + + comma.ai cabana - - - -