-
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.
- Loading branch information
0 parents
commit 6dcc09d
Showing
268 changed files
with
58,166 additions
and
0 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,76 @@ | ||
# Based on https://github.com/plone/volto/blob/master/entrypoint.sh | ||
|
||
FROM node:10-jessie as build | ||
|
||
ARG NPM_CONFIG_REGISTRY | ||
ARG MAX_OLD_SPACE_SIZE=8192 | ||
|
||
ENV NODE_OPTIONS=--max_old_space_size=$MAX_OLD_SPACE_SIZE | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get install -y git bsdmainutils vim-nox mc \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN npm i -g mrs-developer | ||
|
||
WORKDIR /opt/frontend/ | ||
|
||
COPY docker-image.txt / | ||
COPY . . | ||
# RUN chmod +x optimize_node_modules.sh | ||
|
||
RUN mkdir -p /opt/frontend/src/develop | ||
|
||
RUN chown -R node /opt/frontend | ||
|
||
USER node | ||
|
||
RUN echo "prefix = \"/home/node\"\n" > /home/node/.npmrc | ||
RUN rm -rf node_modules .git package-lock.json | ||
|
||
# RUN npm install mr-developer | ||
|
||
#RUN node_modules/.bin/mrdeveloper --config=jsconfig.json --no-config --output=addons | ||
RUN missdev | ||
|
||
RUN make activate-all | ||
|
||
# RUN NPM_CONFIG_REGISTRY=$NPM_CONFIG_REGISTRY npm ci | ||
RUN NPM_CONFIG_REGISTRY=$NPM_CONFIG_REGISTRY npm install | ||
|
||
# RUN ./optimize_node_modules.sh | ||
# RUN make clean-addons | ||
# RUN rm -f package-lock.json | ||
|
||
RUN RAZZLE_API_PATH=VOLTO_API_PATH RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH yarn build | ||
|
||
# Second stage build | ||
FROM node:10-jessie | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get install -y git bsdmainutils vim-nox mc \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /opt/frontend/ | ||
|
||
COPY entrypoint-prod.sh /opt/frontend/entrypoint.sh | ||
RUN chmod +x entrypoint.sh | ||
|
||
COPY package.json . | ||
COPY package-lock.json . | ||
|
||
COPY --from=build /opt/frontend/public ./public | ||
COPY --from=build /opt/frontend/build ./build | ||
|
||
RUN chown -R node /opt/frontend | ||
|
||
USER node | ||
|
||
RUN rm -rf package-lock.json | ||
RUN NPM_CONFIG_REGISTRY=$NPM_CONFIG_REGISTRY npm install --production | ||
|
||
ENTRYPOINT ["/opt/frontend/entrypoint.sh"] | ||
|
||
EXPOSE 3000 3001 4000 4001 | ||
|
||
CMD yarn start:prod |
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,71 @@ | ||
pipeline { | ||
environment { | ||
registry = "eeacms/energy-union-frontend" | ||
template = "templates/volto-energy-union" | ||
dockerImage = '' | ||
tagName = '' | ||
} | ||
|
||
agent any | ||
|
||
stages { | ||
stage('Build & Push') { | ||
steps{ | ||
node(label: 'docker-host') { | ||
script { | ||
checkout scm | ||
if (env.BRANCH_NAME == 'master') { | ||
tagName = 'latest' | ||
} else { | ||
tagName = "$BRANCH_NAME" | ||
} | ||
try { | ||
dockerImage = docker.build("$registry:$tagName", "--no-cache .") | ||
docker.withRegistry( '', 'eeajenkins' ) { | ||
dockerImage.push() | ||
} | ||
} finally { | ||
sh "docker rmi $registry:$tagName" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Release') { | ||
when { | ||
buildingTag() | ||
} | ||
steps{ | ||
node(label: 'docker') { | ||
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { | ||
sh '''docker pull eeacms/gitflow; docker run -i --rm --name="${BUILD_TAG}-release" -e GIT_TOKEN="${GITHUB_TOKEN}" -e RANCHER_CATALOG_PATH="${template}" -e DOCKER_IMAGEVERSION="${BRANCH_NAME}" -e DOCKER_IMAGENAME="${registry}" --entrypoint /add_rancher_catalog_entry.sh eeacms/gitflow''' | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
post { | ||
changed { | ||
script { | ||
def url = "${env.BUILD_URL}/display/redirect" | ||
def status = currentBuild.currentResult | ||
def subject = "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" | ||
def summary = "${subject} (${url})" | ||
def details = """<h1>${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${status}</h1> | ||
<p>Check console output at <a href="${url}">${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}</a></p> | ||
""" | ||
|
||
def color = '#FFFF00' | ||
if (status == 'SUCCESS') { | ||
color = '#00FF00' | ||
} else if (status == 'FAILURE') { | ||
color = '#FF0000' | ||
} | ||
emailext (subject: '$DEFAULT_SUBJECT', to: '$DEFAULT_RECIPIENTS', body: details) | ||
} | ||
} | ||
} | ||
} |
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,134 @@ | ||
image-name-split = $(word $2,$(subst :, ,$1)) | ||
|
||
SHELL=/bin/bash | ||
DOCKERIMAGE_FILE="docker-image.txt" | ||
NAME := $(call image-name-split,$(shell cat $(DOCKERIMAGE_FILE)), 1) | ||
IMAGE=$(shell cat $(DOCKERIMAGE_FILE)) | ||
|
||
# VOLTO_ADDONS=$(shell ./scripts/pkg_helper.py list) | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: activate | ||
activate: ## Activate an addon package for development | ||
set -e; \ | ||
if [[ -z "${pkg}" ]]; then\ | ||
echo "You need to specify package name in make command";\ | ||
echo "Ex: make activate pkg=volto-datablocks";\ | ||
else \ | ||
./scripts/pkg_helper.py --target=${pkg} activate;\ | ||
echo "Running npm install in src/develop/${pkg}";\ | ||
cd "src/addons/$${pkg}";\ | ||
npm install;\ | ||
cd ../..;\ | ||
echo "Cleaning up after npm install";\ | ||
export VOLTO_ADDONS=`./scripts/pkg_helper.py list`;\ | ||
read -ra ADDR <<< "$${VOLTO_ADDONS}"; \ | ||
for pkg in "$${ADDR[@]}"; do \ | ||
echo "removing node_modules/$${pkg}"; \ | ||
rm -rf "./node_modules/$${pkg}";\ | ||
done; \ | ||
echo "Done.";\ | ||
fi | ||
|
||
PHONY: clean-addons | ||
clean-addons: | ||
set -e; \ | ||
echo "Cleaning up after npm install";\ | ||
export VOLTO_ADDONS=`./scripts/pkg_helper.py list`;\ | ||
read -ra ADDR <<< "$${VOLTO_ADDONS}"; \ | ||
for pkg in "$${ADDR[@]}"; do \ | ||
echo "removing node_modules/$${pkg}"; \ | ||
rm -rf "./node_modules/$${pkg}";\ | ||
done; \ | ||
|
||
.PHONY: activate-all | ||
activate-all: ## Automatically activates all addons from mr.developer.json | ||
@echo "Activating all addon packages" | ||
./scripts/pkg_helper.py activate-all | ||
|
||
.PHONY: deactivate | ||
deactivate: ## Deactivate an addon package for development | ||
@if [[ -z "${pkg}" ]]; then\ | ||
echo "You need to specify package name in make command";\ | ||
echo "Ex: make deactivate pkg=volto-datablocks";\ | ||
else \ | ||
exec ./scripts/pkg_helper.py --target=${pkg} deactivate;\ | ||
rm -rf node_modules/${pkg};\ | ||
echo "Deactivated ${pkg}";\ | ||
fi | ||
|
||
.PHONY: all | ||
all: clean build ## (Inside container) build a production version of resources | ||
@echo "Built production files" | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf build/ | ||
|
||
.PHONY: build | ||
build: | ||
echo "";\ | ||
echo "Make sure that you have the npm cache (Verdaccio) running!";\ | ||
echo "";\ | ||
DEBUG= \ | ||
NODE_OPTIONS=--max_old_space_size=4096 \ | ||
RAZZLE_API_PATH=VOLTO_API_PATH \ | ||
RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH \ | ||
yarn build; \ | ||
./entrypoint-prod.sh | ||
|
||
.PHONY: start | ||
start: ## (Inside container) starts production mode frontend server | ||
npm run start:prod | ||
|
||
.PHONY: analyze | ||
analyze: ## (Inside container) build production resources and start bundle analyzer HTTP server | ||
DEBUG= \ | ||
BUNDLE_ANALYZE=true \ | ||
NODE_OPTIONS=--max_old_space_size=4096 \ | ||
RAZZLE_API_PATH=VOLTO_API_PATH \ | ||
RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH \ | ||
yarn build | ||
|
||
.PHONY: release | ||
release: bump build-image push ## (Host side) release a new version of frontend docker image | ||
|
||
.PHONY: bump | ||
bump: | ||
echo "Bumping version..."; | ||
python ./../scripts/version_bump.py $(DOCKERIMAGE_FILE); | ||
|
||
.PHONY: build-image | ||
build-image: | ||
@echo "Building new docker image: $(IMAGE)"; | ||
docker build . --network=host --build-arg MAX_OLD_SPACE_SIZE=4096 --build-arg NPM_CONFIG_REGISTRY=http://127.0.0.1:4873 -t "$(IMAGE)"; | ||
@echo "Image built." | ||
|
||
.PHONY: push | ||
push: | ||
docker push $(IMAGE) | ||
docker tag $(IMAGE) $(NAME):latest | ||
docker push $(NAME):latest | ||
|
||
.PHONY: init-submodules | ||
init-submodules: ## Initialize the git submodules | ||
git submodule update --init --recursive | ||
|
||
.PHONY: develop | ||
develop: ## Runs "git pull" in all addons | ||
./scripts/pkg_helper.py develop | ||
|
||
.PHONY: help | ||
help: ## Show this help. | ||
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" | ||
|
||
.PHONY: build-production | ||
try-production: ## Build production bundle | ||
NODE_OPTIONS=--max_old_space_size=4096 \ | ||
BUNDLE_ANALYZE=true \ | ||
RAZZLE_API_PATH=VOLTO_API_PATH \ | ||
RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH \ | ||
yarn build | ||
./entrypoint-dev.sh | ||
echo "Now run: node build/server.js" |
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,64 @@ | ||
## Energy Union: Volto Frontend | ||
|
||
[![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=energy-union%2Fenergy_union_frontend%2Fmaster&subject=pipeline)](https://ci.eionet.europa.eu/view/Github/job/energy-union/job/energy_union_frontend/job/master/display/redirect) | ||
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/eea/energy_union_frontend?sort=semver)](https://github.com/eea/energy_union_frontend/releases) | ||
|
||
|
||
A frontend component for the Energy Union website. | ||
|
||
## Quick Start | ||
|
||
Below is a list of commands you will probably find useful. | ||
|
||
### `yarn start` | ||
|
||
Runs the project in development mode. | ||
You can view your application at `http://localhost:3000` | ||
|
||
The page will reload if you make edits. | ||
|
||
### `yarn build` | ||
|
||
Builds the app for production to the build folder. | ||
|
||
The build is minified and the filenames include the hashes. | ||
Your app is ready to be deployed! | ||
|
||
### `yarn start:prod` | ||
|
||
Runs the compiled app in production. | ||
|
||
You can again view your application at `http://localhost:3000` | ||
|
||
### `yarn test` | ||
|
||
Runs the test watcher (Jest) in an interactive mode. | ||
By default, runs tests related to files changed since the last commit. | ||
|
||
### `yarn i18n` | ||
|
||
Runs the test i18n runner which extracts all the translation strings and | ||
generates the needed files. | ||
|
||
## Production | ||
|
||
We use [Docker](https://www.docker.com/), [Rancher](https://rancher.com/) and [Jenkins](https://jenkins.io/) to deploy this application in production. | ||
|
||
### Deploy | ||
|
||
* Within `Rancher > Catalog > EEA` deploy [Volto - Energy Union](https://github.com/eea/eea.rancher.catalog/tree/master/templates/volto-energy-union) | ||
|
||
### Release | ||
|
||
* Create a new release of this code via `git tag` command or [Draft new release](https://github.com/eea/energy_union_frontend/releases/new) on Github. | ||
* A new Docker image is built and released automatically on [DockerHub](https://hub.docker.com/r/eeacms/energy-union-frontend) based on this tag. | ||
* A new entry is automatically added to [Volto - Energy Union](https://github.com/eea/eea.rancher.catalog/tree/master/templates/volto-energy-union) `EEA Rancher Catalog` | ||
* The [Jenkins job](https://ci.eionet.europa.eu/blue/organizations/jenkins/energy-union%2Fenergy_union_frontend/) | ||
|
||
### Upgrade | ||
|
||
* Within your Rancher environment click on the `Upgrade available` yellow button next to your stack. | ||
|
||
* Confirm the upgrade | ||
|
||
* Or roll-back if something went wrong and abort the upgrade procedure. |
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,13 @@ | ||
const baseCfg = require('@plone/volto/babel'); | ||
// "react-loadable/babel" | ||
|
||
module.exports = function(api) { | ||
const voltoConfig = baseCfg(api); | ||
const presets = voltoConfig.presets; | ||
const plugins = [...voltoConfig.plugins]; | ||
return { | ||
plugins, | ||
presets, | ||
sourceType: 'unambiguous', | ||
}; | ||
}; |
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 @@ | ||
eeacms/energy-union-frontend:1.6 |
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,26 @@ | ||
#!/usr/bin/env bash | ||
set -Ex | ||
|
||
function apply_path { | ||
mainjs=./build/server.js | ||
bundlejs=./build/public/static/js/*.js | ||
test -f $mainjs | ||
|
||
echo "Check that we have API_PATH and API vars" | ||
test -n "$RAZZLE_API_PATH" | ||
|
||
echo "Changing built files inplace" | ||
sed -i "s#VOLTO_API_PATH#${RAZZLE_API_PATH}#g" $mainjs | ||
sed -i "s#VOLTO_API_PATH#${RAZZLE_API_PATH}#g" $bundlejs | ||
sed -i "s#VOLTO_INTERNAL_API_PATH#${RAZZLE_INTERNAL_API_PATH}#g" $mainjs | ||
sed -i "s#VOLTO_INTERNAL_API_PATH#${RAZZLE_INTERNAL_API_PATH}#g" $bundlejs | ||
|
||
echo "Zipping JS Files" | ||
gzip -fk $mainjs | ||
} | ||
|
||
# Should we monkey patch? | ||
test -n "$RAZZLE_API_PATH" && apply_path | ||
|
||
echo "Starting Volto" | ||
exec "$@" |
Oops, something went wrong.