Skip to content

Commit

Permalink
Merge pull request #151 from qccoders/ops-dev
Browse files Browse the repository at this point in the history
Implement split deployments to development and production environments
  • Loading branch information
jpdillingham authored Sep 15, 2018
2 parents dda959a + 018ac51 commit 6ba653d
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 39 deletions.
81 changes: 54 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,30 @@ matrix:
- npm test
- npm run build
deploy:
provider: s3
access_key_id: AKIAJGLMJSQ5HROL7PTQ
secret_access_key:
secure: Xd6dEKIV6PS8dpZnG234m0R/9OE0Niqz/1kxGDvH2k4sRY0l3yF4WGf3DPvxI5I0jRuJuA/bFgAcGkhvhUG2wmTUawM58TO4jnDkQlSlj5pXuGRiyJiSVxnanRSp63dbfNDM7KCw8M1Tw5XQXKZVUynzbne/EeYs/c+jyAIX8OMMyHMPm1wE5m/cYiAl97AePlLtJhFB0hxG4GbmzNqiBHSuppPViY63wnfv0sfs0leXnPZ9UNEahfbuuFWymZxvJTmpdD5/4UrAw68C7GH8IQ5Z+2oWIlooTteNiDyNiFzX4aCKZ6SfQJAH+HInpPDfR2LKi0xKChb2RLccvW3FnCENyEihNYmELE0uiGHrELBIBZXWFH/8qH+2+4nOWuhEGhmdywTOpIYdOrXTpwxsMCc+42eD12NNeGFRSoOu+nqsDl3ifI3C0ZYrKYb70i78IlAcnki68UwWhvJhSA9TymwXV4INhiiTE3TQhw9duwlwMnxk+PTIhBt2tEjggDIcjCc75r6GTYdhex/r/PEYBL24qVM82GHeOKz0u4Ew85XpU/W9BwKu7tFzI8pxow8F0UCoKkcqDfNioqFx91qmrimFh5Z0GAsh4honixBWqEzBhKRVBNkHVrJ23PxPQBoX8n7EI7ehXGPnb2rVvcSkoQkHsl8NmYZkjYviv2y9ezc=
bucket: qcvoc-prod
skip_cleanup: true
local_dir: build
region: us-east-1
acl: public_read
on:
repo: qccoders/QCVOC
branch: master
- provider: s3
access_key_id: AKIAJGLMJSQ5HROL7PTQ
secret_access_key:
secure: Xd6dEKIV6PS8dpZnG234m0R/9OE0Niqz/1kxGDvH2k4sRY0l3yF4WGf3DPvxI5I0jRuJuA/bFgAcGkhvhUG2wmTUawM58TO4jnDkQlSlj5pXuGRiyJiSVxnanRSp63dbfNDM7KCw8M1Tw5XQXKZVUynzbne/EeYs/c+jyAIX8OMMyHMPm1wE5m/cYiAl97AePlLtJhFB0hxG4GbmzNqiBHSuppPViY63wnfv0sfs0leXnPZ9UNEahfbuuFWymZxvJTmpdD5/4UrAw68C7GH8IQ5Z+2oWIlooTteNiDyNiFzX4aCKZ6SfQJAH+HInpPDfR2LKi0xKChb2RLccvW3FnCENyEihNYmELE0uiGHrELBIBZXWFH/8qH+2+4nOWuhEGhmdywTOpIYdOrXTpwxsMCc+42eD12NNeGFRSoOu+nqsDl3ifI3C0ZYrKYb70i78IlAcnki68UwWhvJhSA9TymwXV4INhiiTE3TQhw9duwlwMnxk+PTIhBt2tEjggDIcjCc75r6GTYdhex/r/PEYBL24qVM82GHeOKz0u4Ew85XpU/W9BwKu7tFzI8pxow8F0UCoKkcqDfNioqFx91qmrimFh5Z0GAsh4honixBWqEzBhKRVBNkHVrJ23PxPQBoX8n7EI7ehXGPnb2rVvcSkoQkHsl8NmYZkjYviv2y9ezc=
bucket: qcvoc-prod
skip_cleanup: true
local_dir: build
region: us-east-1
acl: public_read
on:
repo: qccoders/QCVOC
branch: master
- provider: s3
access_key_id: AKIAJGLMJSQ5HROL7PTQ
secret_access_key:
secure: Xd6dEKIV6PS8dpZnG234m0R/9OE0Niqz/1kxGDvH2k4sRY0l3yF4WGf3DPvxI5I0jRuJuA/bFgAcGkhvhUG2wmTUawM58TO4jnDkQlSlj5pXuGRiyJiSVxnanRSp63dbfNDM7KCw8M1Tw5XQXKZVUynzbne/EeYs/c+jyAIX8OMMyHMPm1wE5m/cYiAl97AePlLtJhFB0hxG4GbmzNqiBHSuppPViY63wnfv0sfs0leXnPZ9UNEahfbuuFWymZxvJTmpdD5/4UrAw68C7GH8IQ5Z+2oWIlooTteNiDyNiFzX4aCKZ6SfQJAH+HInpPDfR2LKi0xKChb2RLccvW3FnCENyEihNYmELE0uiGHrELBIBZXWFH/8qH+2+4nOWuhEGhmdywTOpIYdOrXTpwxsMCc+42eD12NNeGFRSoOu+nqsDl3ifI3C0ZYrKYb70i78IlAcnki68UwWhvJhSA9TymwXV4INhiiTE3TQhw9duwlwMnxk+PTIhBt2tEjggDIcjCc75r6GTYdhex/r/PEYBL24qVM82GHeOKz0u4Ew85XpU/W9BwKu7tFzI8pxow8F0UCoKkcqDfNioqFx91qmrimFh5Z0GAsh4honixBWqEzBhKRVBNkHVrJ23PxPQBoX8n7EI7ehXGPnb2rVvcSkoQkHsl8NmYZkjYviv2y9ezc=
bucket: qcvoc-dev
skip_cleanup: true
local_dir: build
region: us-east-1
acl: public_read
on:
repo: qccoders/QCVOC
branch: develop
- language: csharp
stage: Api
mono: none
Expand All @@ -40,18 +52,33 @@ matrix:
- dotnet publish --configuration Release
- cd QCVOC.Api/bin/Release/netcoreapp2.1/publish
deploy:
provider: lambda
function_name: QCVOC-PROD
region: us-east-1
role: arn:aws:iam::620048899897:role/service-role/QCVOC-Prod-Lambda
runtime: dotnetcore2.1
timeout: 30
memory_size: 256
module_name: QCVOC.Api::QCVOC.Api
handler_name: LambdaEntryPoint::FunctionHandlerAsync
access_key_id: AKIAJGLMJSQ5HROL7PTQ
secret_access_key:
secure: Xd6dEKIV6PS8dpZnG234m0R/9OE0Niqz/1kxGDvH2k4sRY0l3yF4WGf3DPvxI5I0jRuJuA/bFgAcGkhvhUG2wmTUawM58TO4jnDkQlSlj5pXuGRiyJiSVxnanRSp63dbfNDM7KCw8M1Tw5XQXKZVUynzbne/EeYs/c+jyAIX8OMMyHMPm1wE5m/cYiAl97AePlLtJhFB0hxG4GbmzNqiBHSuppPViY63wnfv0sfs0leXnPZ9UNEahfbuuFWymZxvJTmpdD5/4UrAw68C7GH8IQ5Z+2oWIlooTteNiDyNiFzX4aCKZ6SfQJAH+HInpPDfR2LKi0xKChb2RLccvW3FnCENyEihNYmELE0uiGHrELBIBZXWFH/8qH+2+4nOWuhEGhmdywTOpIYdOrXTpwxsMCc+42eD12NNeGFRSoOu+nqsDl3ifI3C0ZYrKYb70i78IlAcnki68UwWhvJhSA9TymwXV4INhiiTE3TQhw9duwlwMnxk+PTIhBt2tEjggDIcjCc75r6GTYdhex/r/PEYBL24qVM82GHeOKz0u4Ew85XpU/W9BwKu7tFzI8pxow8F0UCoKkcqDfNioqFx91qmrimFh5Z0GAsh4honixBWqEzBhKRVBNkHVrJ23PxPQBoX8n7EI7ehXGPnb2rVvcSkoQkHsl8NmYZkjYviv2y9ezc=
on:
repo: qccoders/QCVOC
branch: master
- provider: lambda
function_name: QCVOC-DEV
region: us-east-1
role: arn:aws:iam::620048899897:role/service-role/QCVOC-Prod-Lambda
runtime: dotnetcore2.1
timeout: 30
memory_size: 256
module_name: QCVOC.Api::QCVOC.Api
handler_name: LambdaEntryPoint::FunctionHandlerAsync
access_key_id: AKIAJGLMJSQ5HROL7PTQ
secret_access_key:
secure: Xd6dEKIV6PS8dpZnG234m0R/9OE0Niqz/1kxGDvH2k4sRY0l3yF4WGf3DPvxI5I0jRuJuA/bFgAcGkhvhUG2wmTUawM58TO4jnDkQlSlj5pXuGRiyJiSVxnanRSp63dbfNDM7KCw8M1Tw5XQXKZVUynzbne/EeYs/c+jyAIX8OMMyHMPm1wE5m/cYiAl97AePlLtJhFB0hxG4GbmzNqiBHSuppPViY63wnfv0sfs0leXnPZ9UNEahfbuuFWymZxvJTmpdD5/4UrAw68C7GH8IQ5Z+2oWIlooTteNiDyNiFzX4aCKZ6SfQJAH+HInpPDfR2LKi0xKChb2RLccvW3FnCENyEihNYmELE0uiGHrELBIBZXWFH/8qH+2+4nOWuhEGhmdywTOpIYdOrXTpwxsMCc+42eD12NNeGFRSoOu+nqsDl3ifI3C0ZYrKYb70i78IlAcnki68UwWhvJhSA9TymwXV4INhiiTE3TQhw9duwlwMnxk+PTIhBt2tEjggDIcjCc75r6GTYdhex/r/PEYBL24qVM82GHeOKz0u4Ew85XpU/W9BwKu7tFzI8pxow8F0UCoKkcqDfNioqFx91qmrimFh5Z0GAsh4honixBWqEzBhKRVBNkHVrJ23PxPQBoX8n7EI7ehXGPnb2rVvcSkoQkHsl8NmYZkjYviv2y9ezc=
on:
repo: qccoders/QCVOC
branch: develop
- provider: lambda
function_name: QCVOC-PROD
region: us-east-1
role: arn:aws:iam::620048899897:role/service-role/QCVOC-Prod-Lambda
runtime: dotnetcore2.1
timeout: 30
memory_size: 256
module_name: QCVOC.Api::QCVOC.Api
handler_name: LambdaEntryPoint::FunctionHandlerAsync
access_key_id: AKIAJGLMJSQ5HROL7PTQ
secret_access_key:
secure: Xd6dEKIV6PS8dpZnG234m0R/9OE0Niqz/1kxGDvH2k4sRY0l3yF4WGf3DPvxI5I0jRuJuA/bFgAcGkhvhUG2wmTUawM58TO4jnDkQlSlj5pXuGRiyJiSVxnanRSp63dbfNDM7KCw8M1Tw5XQXKZVUynzbne/EeYs/c+jyAIX8OMMyHMPm1wE5m/cYiAl97AePlLtJhFB0hxG4GbmzNqiBHSuppPViY63wnfv0sfs0leXnPZ9UNEahfbuuFWymZxvJTmpdD5/4UrAw68C7GH8IQ5Z+2oWIlooTteNiDyNiFzX4aCKZ6SfQJAH+HInpPDfR2LKi0xKChb2RLccvW3FnCENyEihNYmELE0uiGHrELBIBZXWFH/8qH+2+4nOWuhEGhmdywTOpIYdOrXTpwxsMCc+42eD12NNeGFRSoOu+nqsDl3ifI3C0ZYrKYb70i78IlAcnki68UwWhvJhSA9TymwXV4INhiiTE3TQhw9duwlwMnxk+PTIhBt2tEjggDIcjCc75r6GTYdhex/r/PEYBL24qVM82GHeOKz0u4Ew85XpU/W9BwKu7tFzI8pxow8F0UCoKkcqDfNioqFx91qmrimFh5Z0GAsh4honixBWqEzBhKRVBNkHVrJ23PxPQBoX8n7EI7ehXGPnb2rVvcSkoQkHsl8NmYZkjYviv2y9ezc=
on:
repo: qccoders/QCVOC
branch: master
4 changes: 2 additions & 2 deletions web/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import axios from 'axios';
import { getCredentials, updateCredentials, deleteCredentials } from './credentialStore';
import { API_ROOT } from './constants';
import { getEnvironment } from './util';

axios.defaults.baseURL = API_ROOT;
axios.defaults.baseURL = getEnvironment().apiRoot;

const api = axios.create();

Expand Down
6 changes: 5 additions & 1 deletion web/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Events from '../events/Events';
import LoginForm from '../security/LoginForm';
import LinkList from './LinkList';
import { CircularProgress, ListSubheader } from '@material-ui/core';
import { getEnvironment } from '../util';

const styles = {
root: {
Expand Down Expand Up @@ -123,6 +124,8 @@ class App extends Component {
let { isExecuting, isErrored } = this.state.api;
let { accessToken, role } = this.state.credentials;

let env = getEnvironment();

return (
<div className={classes.root}>
{isExecuting || isErrored ? <CircularProgress size={20} style={styles.spinner}/>:
Expand All @@ -131,6 +134,7 @@ class App extends Component {
<AppBar
title='QCVOC'
drawerToggleButton={<DrawerToggleButton onToggleClick={this.handleToggleDrawer}/>}
color={env.color}
>
<SecurityMenu
credentials={this.state.credentials}
Expand All @@ -143,7 +147,7 @@ class App extends Component {
onClose={this.handleToggleDrawer}
PaperProps={{style: styles.drawer}}
>
<AppBar title='QCVOC'/>
<AppBar title='QCVOC' color={env.color}/>
<LinkList onLinkClick={this.handleToggleDrawer}>
<Link to='/veterans' icon={<People/>}>Veterans</Link>
<Link to='/events' icon={<InsertInvitation/>}>Events</Link>
Expand Down
3 changes: 2 additions & 1 deletion web/src/app/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Typography from '@material-ui/core/Typography';

const AppBar = (props) => {
return (
<MaterialAppBar position="static" color="primary">
<MaterialAppBar position="static" color={props.color ? props.color : "primary"}>
<Toolbar>
{props.drawerToggleButton}
<Typography variant="title" color="inherit">
Expand All @@ -28,6 +28,7 @@ AppBar.propTypes = {
title: PropTypes.string,
drawerToggleButton: PropTypes.object,
children: PropTypes.object,
color: PropTypes.string,
};

export default AppBar;
6 changes: 0 additions & 6 deletions web/src/constants.js

This file was deleted.

18 changes: 18 additions & 0 deletions web/src/environments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright (c) QC Coders (JP Dillingham, Nick Acosta, Will Burklund, et. al.). All rights reserved. Licensed under the GPLv3 license. See LICENSE file
in the project root for full license information.
*/

export const PROD = {
name: 'prod',
hostname: 'qcvoc.qccoders.org',
apiRoot: 'https://4olgsguu53.execute-api.us-east-1.amazonaws.com/prod/api',
color: 'primary',
}

export const DEV = {
name: 'dev',
hostname: 'dev.qcvoc.qccoders.org',
apiRoot: 'https://p0krgyy73g.execute-api.us-east-1.amazonaws.com/dev/api',
color: 'default',
}
4 changes: 2 additions & 2 deletions web/src/security/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';

import { API_ROOT } from '../constants';
import { getEnvironment } from '../util';
import { withStyles } from '@material-ui/core/styles';

import { Card, CardContent, CardActions, CircularProgress } from '@material-ui/core';
Expand Down Expand Up @@ -108,7 +108,7 @@ class LoginForm extends Component {
validation: { name: undefined, password: undefined },

}, () => {
axios.post(API_ROOT + '/v1/security/login', this.state)
axios.post(getEnvironment().apiRoot + '/v1/security/login', this.state)
.then(
response => {
this.props.onLogin(response.data, this.state.rememberMe);
Expand Down
11 changes: 11 additions & 0 deletions web/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Copyright (c) QC Coders (JP Dillingham, Nick Acosta, Will Burklund, et. al.). All rights reserved. Licensed under the GPLv3 license. See LICENSE file
in the project root for full license information.
*/

import { PROD, DEV } from './environments';

export const sortByProp = (prop, predicate = 'asc') => {
return (a, b) => {
a = a[prop];
Expand All @@ -20,6 +23,14 @@ export const sortByProp = (prop, predicate = 'asc') => {
}
}

export const getEnvironment = () => {
if (window.location.hostname !== PROD.hostname) {
return DEV;
}

return PROD;
}

export const getGuid = () => {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
Expand Down

0 comments on commit 6ba653d

Please sign in to comment.