cruise-automation / webviz

web-based visualization libraries
https://webviz.io/
Apache License 2.0
2.01k stars 408 forks source link

automatic github action to build webviz #267

Open stefan-enway opened 4 years ago

stefan-enway commented 4 years ago

you need to be in github action beta (will be public November 13th; two days), enable docker registry in github (repo "packages" section).

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: npm bootstrap & build
      run: |
        npm run bootstrap
        npm run build --if-present
        #npm run docs (runs webserver)
      env:
        CI: true
    - uses: elgohr/Publish-Docker-Github-Action@master
      with:
        name: cruise-automation/webviz/webwiz:latest
        registry: docker.pkg.github.com
        dockerfile: Dockerfile
        username: <your-automation-username-here->
        password: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

# Copyright (c) 2018-present, GM Cruise LLC
#
# This source code is licensed under the Apache License, Version 2.0,
# found in the LICENSE file in the root directory of this source tree.
# You may not use this file except in compliance with the License.

# This container is published at https://hub.docker.com/r/cruise/webviz-ci.

FROM node:10.15.3-slim

# Install some general dependencies for stuff below and for CircleCI;
# https://circleci.com/docs/2.0/custom-images/#required-tools-for-primary-containers
RUN apt-get update && apt-get install -yq libgconf-2-4 wget git ssh --no-install-recommends

# Install Google Chrome for Puppeteer.
# https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont --no-install-recommends
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

ENV WEBVIZ_IN_DOCKER=true

# Bumped up from the default old_space size (512mb) as it was being exceeded during builds.
ENV NODE_OPTIONS="--max_old_space_size=4096"

Copy . .

RUN npm run bootstrap

RUN npm run build

then run like docker run -p 8080:8080 webviz:latest npm run docs and you will have webviz running at port 8080 of the docker host. beware you need to patch webpack.config.js to be running in docker:

  devServer: {
    contentBase: path.resolve(`${__dirname}/docs/public`),
    hot: true,
    open: true,
    host: '0.0.0.0', // fixes docker port binding
    public: '<hostname-of-your-docker-host>:8080'
  },

i am working on an nginx setup for proper TLS/letzsencrypt/443 setup that could be used on the internet with proper CORS support

stefan-enway commented 4 years ago

will make a nice PR later, just wanted to let you know that it works