-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from geostreams/release/3.5.0
Release/3.5.0
- Loading branch information
Showing
85 changed files
with
1,642 additions
and
123,127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*Dockerfile* | ||
*docker-compose* | ||
node_modules | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.