-
Notifications
You must be signed in to change notification settings - Fork 5
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 #187 from WorldBank-Transport/develop
Release new version
- Loading branch information
Showing
18 changed files
with
3,048 additions
and
2,190 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
#!/usr/bin/env bash | ||
set -e # halt script on error | ||
|
||
# This scripts builds the site and moves it to the Nginx folder. | ||
# To be run as a command in docker-compose | ||
|
||
# Build the site | ||
if [[ $DS_ENV == 'offline' ]]; then | ||
echo 'Building version for offline use' | ||
yarn build-offline | ||
else | ||
echo 'Building production version' | ||
yarn build | ||
fi | ||
|
||
# Clean default nginx content | ||
rm -r /usr/share/nginx/html/* | ||
mv ./dist/* /usr/share/nginx/html | ||
|
||
# Make sure nginx stays up once the container is done | ||
echo "daemon off;" >> /etc/nginx/nginx.conf || true | ||
|
||
echo 'Starting nginx, access the RAM frontend through your browser.' | ||
|
||
# Start nginx | ||
nginx | ||
|
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,83 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:8 | ||
|
||
working_directory: ~/repo | ||
|
||
environment: | ||
- STAGING_BRANCH: develop | ||
- PRODUCTION_BRANCH: master | ||
- DOCKER_IMAGE: ram-frontend | ||
- DOCKER_ORG: wbtransport | ||
- GH_REF: [email protected]:WorldBank-Transport/ram-backend.git | ||
- GH_NAME: "Development Seed" | ||
- GH_EMAIL: "[email protected]" | ||
|
||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
|
||
- add_ssh_keys: | ||
fingerprints: | ||
- "ed:c1:81:ac:c3:74:2f:61:0c:8e:40:fd:7a:f2:7e:07" | ||
|
||
# # Download and cache dependencies | ||
# - restore_cache: | ||
# keys: | ||
# - v1-dependencies-{{ checksum "package.json" }} | ||
# # fallback to using the latest cache if no exact match is found | ||
# - v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
# - save_cache: | ||
# paths: | ||
# - node_modules | ||
# key: v1-dependencies-{{ checksum "package.json" }} | ||
|
||
- run: yarn lint | ||
|
||
- run: | ||
name: Build Docker image for dev version | ||
command: | | ||
if [ ${CIRCLE_BRANCH} == ${STAGING_BRANCH} ]; then | ||
echo "Building Docker image" | ||
docker build -t ${DOCKER_IMAGE} . | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWD | ||
echo "Pushing image to Docker Hub as :latest-dev" | ||
docker tag ${DOCKER_IMAGE} ${DOCKER_ORG}/${DOCKER_IMAGE}:latest-dev | ||
docker push ${DOCKER_ORG}/${DOCKER_IMAGE}:latest-dev | ||
else | ||
echo "This is not the "${STAGING_BRANCH}" branch. No need to build and push latest-dev." | ||
fi | ||
- deploy: | ||
name: Build Docker image for stable version | ||
command: | | ||
if [ "${CIRCLE_BRANCH}" == "${PRODUCTION_BRANCH}" ]; then | ||
# Grab version from package.json and prepend with v (v0.5.0) | ||
VERSION=v$(grep -m1 version package.json | awk -F: '{ print $2 }' | sed 's/[", ]//g') | ||
# Attempt to add a git tag based on version in package.json. If | ||
# the tag already exists, git will fail and stop the build. | ||
if ! git tag ${VERSION} master | ||
then | ||
echo >&2 "Failed to tag a new release, skipping build. Did you update the version in package.json?" | ||
exit 1 | ||
else | ||
# Push tag to Github | ||
git push origin ${VERSION} | ||
echo Building Docker image | ||
docker build -t ${DOCKER_IMAGE} . | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWD | ||
echo Pushing image to Docker Hub with ${VERSION} tag | ||
docker tag ${DOCKER_IMAGE} ${DOCKER_ORG}/${DOCKER_IMAGE}:${VERSION} | ||
docker push ${DOCKER_ORG}/${DOCKER_IMAGE}:${VERSION} | ||
fi | ||
else | ||
echo "This is not the "${PRODUCTION_BRANCH}" branch. No need to build and push new version." | ||
fi |
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,8 @@ | ||
.git | ||
.tmp | ||
.eslintrc | ||
.travis.yml | ||
.gitignore | ||
.gitattributes | ||
node_modules | ||
dist |
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 +1 @@ | ||
6 | ||
8 |
This file was deleted.
Oops, something went wrong.
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,2 +1,15 @@ | ||
FROM nginx:alpine | ||
COPY dist /usr/share/nginx/html | ||
# https://github.com/ExiaSR/alpine-yarn-nginx | ||
FROM exiasr/alpine-yarn-nginx | ||
|
||
# Add build dependencies | ||
RUN apk add --no-cache make gcc g++ python | ||
|
||
COPY . /source | ||
WORKDIR /source | ||
RUN yarn install | ||
|
||
# Remove them to keep image size small | ||
RUN apk del make gcc g++ python | ||
|
||
# Build and serve the site | ||
CMD ["sh", "/source/.build_scripts/serve.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,29 @@ | ||
'use strict'; | ||
var defaultsDeep = require('lodash').defaultsDeep; | ||
/* | ||
* App configuration. | ||
* | ||
* Uses settings in config/production.js, with any properties set by | ||
* config/staging.js or config/local.js overriding them depending upon the | ||
* environment. | ||
* | ||
* This file should not be modified. Instead, modify one of: | ||
* | ||
* - config/production.js | ||
* Production settings (base). | ||
* - config/staging.js | ||
* Overrides to production if ENV is staging. | ||
* - config/local.js | ||
* Overrides if local.js exists. | ||
* This last file is gitignored, so you can safely change it without | ||
* polluting the repo. | ||
*/ | ||
const _ = require('lodash'); | ||
|
||
var configurations = require('./config/*.js', {mode: 'hash'}); | ||
var config = configurations.local || {}; | ||
// Empty template as base. | ||
var config = require('./config/base'); | ||
|
||
// local config overrides when present. | ||
try { | ||
_.merge(config, require('./config/local')); | ||
} catch (e) { | ||
// Local file is not mandatory. | ||
} | ||
|
||
// In an offline setup, the other config files are ignored | ||
if (process.env.DS_ENV === 'offline') { | ||
config = configurations.offline; | ||
} else { | ||
if (process.env.DS_ENV === 'staging') { | ||
defaultsDeep(config, configurations.staging); | ||
} | ||
defaultsDeep(config, configurations.production); | ||
config = require('./config/offline'); | ||
} | ||
|
||
config.api = process.env.API || config.api; | ||
config.iDEditor = process.env.IDEDITOR || config.iDEditor; | ||
config.mbtoken = process.env.MBTOKEN || config.mbtoken; | ||
|
||
// auth is an empty object, unless one of the environment vars is set | ||
if (process.env.AUTH_DOMAIN) config.auth.domain = process.env.AUTH_DOMAIN; | ||
if (process.env.AUTH_CLIENTID) config.auth.clientID = process.env.AUTH_CLIENTID; | ||
if (process.env.AUTH_REDIRECTURI) config.auth.redirectUri = process.env.AUTH_REDIRECTURI; | ||
if (process.env.AUTH_AUDIENCE) config.auth.audience = process.env.AUTH_AUDIENCE; | ||
|
||
module.exports = config; |
Oops, something went wrong.