Skip to content

Commit

Permalink
Merge pull request #17 from geostreams/release/3.5.0
Browse files Browse the repository at this point in the history
Release/3.5.0
  • Loading branch information
lmarini authored Oct 2, 2020
2 parents 0315921 + 5645728 commit ec0e6cf
Show file tree
Hide file tree
Showing 85 changed files with 1,642 additions and 123,127 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*Dockerfile*
*docker-compose*
node_modules
**/node_modules
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.*/gd-gltg__old/.*
.*/gd-ilnlrs__old/.*
.*/gd-imlczo__old/.*
.*/node_modules/@mapbox/jsonlint-lines-primitives/test/fails/.*\.json$

[include]

Expand Down
174 changes: 174 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# This action file handles the deployment of geodashboard projects.
# - Builds docker images for each project details provided.
# - Pushes images to hub.ncsa.illinois.edu with their respective tags
# - Sets up SSH to VM's and pulls the new images
name: Geodashboard Projects Build & Deploy

# Controls when the action will run. Triggers the workflow on push
# events for master and develop branches only.
on:
push:
branches:
- master
- develop

jobs:
build-push:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
name:
- gltg
# - glm
# - imlczo
# - ilnrs
- smartfarm
include:
- name: gltg
gd-name: gd-gltg
# prod-host: "greatlakestogulf.org"
dev-host: "gltg-dev.ncsa.illinois.edu"
file-path: /home/ubuntu/gltg
description: "GLTG Geodashboard Image"
# Cannot directly get secrets value here hence
# passing on the name of the secrets variable. Used in ga_token step
ga-token-ref: GLTG_GA_TOKEN
# - name: glm
# gd-name: gd-glm
# prod-host: greatlakesmonitoring.org
# dev-host: seagrant-dev.ncsa.illinois.edu
# file-path: /home/ubuntu/glm
# description: "GLM Geodashboard Image"
# - name: imlczo
# gd-name: gd-imlczo__old
# prod-host: "."
# dev-host: "."
# file-path: "."
# description: "IMLCZO Geodashboard Image"
# - name: ilnlrs
# gd-name: gd-ilnlrs__old
# prod-host: "."
# dev-host: "."
# file-path: "."
# description: "ILNLRS Geodashboard Image"
- name: smartfarm
gd-name: gd-smartfarm
prod-host: ""
dev-host: "141.142.208.219"
file-path: /home/ubuntu/smartfarm
description: "Smartfarm Geodashboard Image"
steps:
-
name: Checkout
uses: actions/checkout@v2
-
# Generates the tags and gets the version number from package.json files
# For develop branch, images are tagged with `develop` and the git sha of the latest commit
# For master branch, images are tagged with `latest` and the version number in their package.json
# Images are names according to their project-name in geodashboard repository.
# i.e. gltg development image is named geostreams/gd-gltg:dev
name: Gather Information
id: info
env:
PROJECT_NAME: ${{ matrix.gd-name }}
HUB_REPO: hub.ncsa.illinois.edu/geostreams
GITHUB_SHA: ${{ github.sha }}
run: |
TARGET_BRANCH=${GITHUB_REF#refs/*/}
GD_VERSION="$(grep version package.json | awk -F \" '{print $4}')"
VERSION="$(grep version $PROJECT_NAME/package.json | awk -F \" '{print $4}')"
echo -n > .env
if [ "$TARGET_BRANCH" == "master" ]; then
TAGS="${HUB_REPO}/${PROJECT_NAME}:latest,${HUB_REPO}/${PROJECT_NAME}:${VERSION}"
echo ::set-env name=HOST:: ${{ matrix.prod-host }}
elif [ "$TARGET_BRANCH" == "develop" ]; then
TAGS="${HUB_REPO}/${PROJECT_NAME}:develop"
TAGS="$TAGS,${HUB_REPO}/${PROJECT_NAME}:sha-${GITHUB_SHA::8}"
echo ::set-env name=SSH_HOST:: ${{ matrix.dev-host }}
fi
echo "::set-output name=version::${VERSION}"
echo "::set-output name=tags::${TAGS}"
echo "::set-output name=gd-version::${GD_VERSION}"
echo "::set-output name=buildargs::PROJECT_NAME=$PROJECT_NAME"
echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
-
# Adds the GA Token to .env file used by dockerfile for npm
name: Add Google Analytics Token
id: ga_token
if: contains(github.ref, 'master') && matrix.ga-token-ref
env:
GA_TOKEN: ${{ secrets[matrix.ga-token-ref] }}
run: |
echo "GA_TOKEN=$GA_TOKEN" > .env
cat .env
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker 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 Hub
uses: docker/login-action@v1
with:
registry: hub.ncsa.illinois.edu
username: ${{ secrets.HUB_USERNAME }}
password: ${{ secrets.HUB_PASSWORD }}
-
# Docker build and push action.
# Attaches tags generated above and labels to the image before pushing
name: Build and Push Image
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
context: .
file: ./Dockerfile
tags: ${{ steps.info.outputs.tags }}
build-args: |
${{ steps.info.outputs.buildargs }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
labels: |
image.title= ${{ matrix.description }}
image.version=${{ steps.info.outputs.version }}
image.geodashboard-version=${{ steps.info.outputs.gd-version }}
image.created=${{ steps.info.outputs.created }}
image.revision=${{ github.sha }}
-
name: Setup SSH to VM
if: ${{ env.SSH_HOST }}
env:
SSH_HOST: ${{ env.SSH_HOST }}
SSH_KEY: ${{ secrets.SSH_KEY }}
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/deploy_key.pem
chmod 600 ~/.ssh/deploy_key.pem
cat >>~/.ssh/config <<END
Host vm
HostName $SSH_HOST
User ubuntu
IdentityFile ~/.ssh/deploy_key.pem
StrictHostKeyChecking no
END
-
# Establishes SSH connection to the VM, pulls most recent image and starts it up
name: Update Image in VM
if: ${{ env.SSH_HOST }}
env:
HUB_USER: ${{ secrets.HUB_USERNAME }}
HUB_PASS: ${{ secrets.HUB_PASSWORD }}
FILE_PATH: ${{ matrix.file-path }}
run: |
ssh vm "sudo docker login -u '$HUB_USER' -p '$HUB_PASS' hub.ncsa.illinois.edu"
ssh vm "sleep 5 && cd $FILE_PATH && sudo docker-compose pull geodashboard && sudo docker-compose up -d"
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.5.0] - 2020-08-27
See `gd-gltg/CHANGELOG.md`, `gd-geostreaming/CHANGELOG.md`, `gd-glm__old`, `gd-glm` for specific changes.

### Added
- New BPM dashboard `gd-gltg-bmp`.
- Created new project for Smartfarm
[SMARTFARM-2](https://opensource.ncsa.illinois.edu/jira/browse/SMARTFARM-2)
- Added support for url path context
[GLGVO-692](https://opensource.ncsa.illinois.edu/jira/browse/GLGVO-692)
- Setup Github Actions for building and deploying docker images
### Changed
- Update dependencies
[Issue-3](https://github.com/geostreams/geodashboard/issues/3)
- Removed `connected-react-router`
[Issue-12](https://github.com/geostreams/geodashboard/issues/12)

## [3.4.0] - 2020-08-27
- See `gd-core/CHANGELOG.md`, `gd-glm/CHANGELOG.md` and `gd-glm_old/CHANGELOG.md` for changes.
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Takes the project name as input and builds an image for the
# specific project. The build files are served with nginx.

ARG PROJECT_NAME=''

FROM node:12-alpine as build

WORKDIR /geodashboard
COPY . .
RUN apk add git
RUN apk add openssh
RUN git submodule init
RUN git submodule update
RUN npm run clean
RUN npm i --quiet
RUN npm run postinstall

ARG PROJECT_NAME
# Loads environment variables for npm if .env file present
RUN [ -f .env ] && set -a . .env && set +a; npm run build -- $PROJECT_NAME


FROM nginx:stable-alpine
ARG PROJECT_NAME
RUN rm /etc/nginx/conf.d/default.conf
COPY docker/nginx.conf /etc/nginx/conf.d

COPY --from=build /geodashboard/$PROJECT_NAME/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,11 @@ passed to it after its initialization.

See `index.jsx`, `routes.js` and `reducers/index.js` in `gd-geostreaming/src` for an example of how routes and reducers
can be set up.

### Environment variables

This a list of high level environment variables. For project-specific variables, see their README file in their folders.

| Variable | Type | Default | Description |
|----------|------|---------|-------------|
| CONTEXT | string | | The url path context the app is running in, e.g. `CONTEXT=/bmp` |
11 changes: 11 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html; }
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
26 changes: 13 additions & 13 deletions gd-core/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// @flow
import React from 'react';
import { connect } from 'react-redux';
import * as React from 'react';
import { Route } from 'react-router-dom';
import { ThemeProvider } from '@material-ui/core/styles';

import theme from './theme';
import { entries } from './utils/array';

type Props = {
routes: { [key: string]: Function };
pathname: string;
}

const App = ({ routes }: Props) => Object
.entries(routes)
.map(([path, props]) => (
<Route key={path} path={path} {...props} />
));

const mapStateToProps = (state) => ({
pathname: state.router.location.pathname
});
const App = ({ routes }: Props) => (
<ThemeProvider theme={theme}>
{entries(routes).map(([path, props]) => (
<Route key={path} path={`${process.env.CONTEXT || ''}${path}`} {...props} />
))}
</ThemeProvider>
);

export default connect(mapStateToProps)(App);
export default App;
6 changes: 0 additions & 6 deletions gd-core/src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// @flow
import { createBrowserHistory } from 'history';
import { connectRouter } from 'connected-react-router';

import page from './page';

export const history = createBrowserHistory();

export default {
router: connectRouter(history),
page
};
15 changes: 5 additions & 10 deletions gd-core/src/render.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import * as React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { ConnectedRouter, routerMiddleware } from 'connected-react-router';
import { ThemeProvider } from '@material-ui/core/styles';

import App from './App';
import baseReducers, { history } from './reducers';
import baseReducers from './reducers';
import baseRoutes from './routes';
import theme from './theme';

import type { Routes } from './routes';

Expand All @@ -25,7 +23,6 @@ const render = (
const store = createStore(
combineReducers(reducers),
composeEnhancers(applyMiddleware(
routerMiddleware(history),
thunk
))
);
Expand All @@ -39,11 +36,9 @@ const render = (
if (root) {
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<ThemeProvider theme={theme}>
<App routes={routes} />
</ThemeProvider>
</ConnectedRouter>
<Router>
<App routes={routes} />
</Router>
</Provider>,
root
);
Expand Down
2 changes: 1 addition & 1 deletion gd-core/webpack.config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const FaviconsWebpackPlugin = require('favicons-webpack-plugin');

const commonConfigBase = require('../webpack.config.common');

module.exports = webpackMerge(
module.exports = webpackMerge.merge(
commonConfigBase,
{
entry: {
Expand Down
2 changes: 1 addition & 1 deletion gd-core/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const webpackMerge = require('webpack-merge');
const devConfigBase = require('../webpack.config.dev');
const commonConfigCore = require('./webpack.config.common');

module.exports = webpackMerge(commonConfigCore, devConfigBase);
module.exports = webpackMerge.merge(commonConfigCore, devConfigBase);
2 changes: 1 addition & 1 deletion gd-core/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const webpackMerge = require('webpack-merge');
const prodConfigBase = require('../webpack.config.prod');
const commonConfigCore = require('./webpack.config.common');

module.exports = webpackMerge(commonConfigCore, prodConfigBase);
module.exports = webpackMerge.merge(commonConfigCore, prodConfigBase);
Loading

0 comments on commit ec0e6cf

Please sign in to comment.