Skip to content

Commit

Permalink
Upgrade to volto 7
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Aug 21, 2020
1 parent 1ad1bb2 commit e5785d2
Show file tree
Hide file tree
Showing 212 changed files with 17,562 additions and 57,930 deletions.
63 changes: 0 additions & 63 deletions .eslintrc

This file was deleted.

41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const jsConfig = require('./jsconfig').compilerOptions;
const path = require('path');
const projectRootPath = __dirname;
const packageJson = require(path.join(projectRootPath, 'package.json'));

const pathsConfig = jsConfig.paths;
let voltoPath = './node_modules/@plone/volto';
Object.keys(pathsConfig).forEach((pkg) => {
if (pkg === '@plone/volto') {
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
}
});

const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
const reg = new AddonConfigurationRegistry(__dirname);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonAliases = Object.keys(reg.packages).map((o) => [
o,
reg.packages[o].modulePath,
]);

module.exports = {
extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
settings: {
'import/resolver': {
alias: {
map: [
['@plone/volto', '@plone/volto/src'],
...addonAliases,
['@package', `${__dirname}/src`],
['~', `${__dirname}/src`],
],
extensions: ['.js', '.jsx', '.json'],
},
'babel-plugin-root-import': {
rootPathSuffix: 'src',
},
},
},
};
76 changes: 8 additions & 68 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,76 +1,16 @@
# Based on https://github.com/plone/volto/blob/master/entrypoint.sh
FROM node:12-stretch-slim

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/*
COPY . /opt/frontend/
RUN chown -R node /opt/frontend/

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"]
RUN RAZZLE_API_PATH=VOLTO_API_PATH RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH yarn \
&& RAZZLE_API_PATH=VOLTO_API_PATH RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH yarn build \
&& rm -rf /home/node/.cache

EXPOSE 3000 3001 4000 4001

CMD yarn start:prod
ENTRYPOINT ["/opt/frontend/entrypoint-prod.sh"]
CMD ["yarn", "start:prod"]
15 changes: 5 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pipeline {
environment {
registry = "eeacms/eprtr-frontend"
template = "templates/volto-eprtr"
RANCHER_STACKID = "1st1851"
RANCHER_ENVID = "1a332957"
registry = "eeacms/ims-frontend"
template = "templates/volto-ims"
dockerImage = ''
tagName = ''
}
Expand All @@ -12,9 +10,6 @@ pipeline {

stages {
stage('Build & Push') {
when {
buildingTag()
}
steps{
node(label: 'docker-host') {
script {
Expand All @@ -25,7 +20,7 @@ pipeline {
tagName = "$BRANCH_NAME"
}
try {
dockerImage = docker.build registry + ":" + tagName
dockerImage = docker.build("$registry:$tagName", "--no-cache .")
docker.withRegistry( '', 'eeajenkins' ) {
dockerImage.push()
}
Expand All @@ -50,7 +45,7 @@ pipeline {
}
}

stage('Upgrade demo') {
stage('Upgrade demo') {
when {
buildingTag()
}
Expand All @@ -64,7 +59,7 @@ pipeline {
}
}
}

}

post {
Expand Down
91 changes: 63 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,94 @@
## Energy Union: Volto Frontend
# IMS: 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)
[![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto%2Fims-frontend%2Fmaster&subject=pipeline)](https://ci.eionet.europa.eu/view/Github/job/volto/job/ims-frontend/job/master/display/redirect)
[![Release](https://img.shields.io/github/v/release/eea/ims-frontend?sort=semver)](https://github.com/eea/ims-frontend/releases)

## Documentation

A frontend component for the Energy Union website.
A training on how to create your own website using Volto is available as part of the Plone training at [https://training.plone.org/5/volto/index.html](https://training.plone.org/5/volto/index.html).

## Quick Start

Below is a list of commands you will probably find useful.
## Getting started

### `yarn start`
1. Clone:

Runs the project in development mode.
You can view your application at `http://localhost:3000`
$ git clone https://github.com/eea/ims-frontend.git
$ cd ims-frontend

The page will reload if you make edits.
1. Install `nvm`

### `yarn build`
$ touch ~/.bash_profile
$ curl -o- https://github.com/raw/creationix/nvm/v0.34.0/install.sh | bash

Builds the app for production to the build folder.
$ source ~/.bash_profile
$ nvm version

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
1. Install latest `NodeJS 12.x`:

### `yarn start:prod`
$ nvm install 12
$ nvm use 12
$ node -v
v12.16.2

Runs the compiled app in production.
1. Install `yarn`

You can again view your application at `http://localhost:3000`
$ curl -o- -L https://yarnpkg.com/install.sh | bash
$ yarn -v

### `yarn test`
1. Install

Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.
$ yarn

### `yarn i18n`
1. Start and setup backend

$ docker-compose up -d

* Go to `http://localhost:8080` [Advanced](http://localhost:8080/@@plone-addsite?site_id=Plone&advanced=1):
* Add `Plone` site with add-ons enabled (**user:** `admin`, **password:** `admin`):
* `kitconcept.volto`

1. Start frontend

$ yarn start

1. See application at http://localhost:3000

## Try it

1. Install [Docker](https://docs.docker.com/install/)
1. Install [Docker Compose](https://docs.docker.com/compose/install/)
1. Start:

$ git clone https://github.com/eea/ims-frontend.git
$ cd ims-frontend

$ docker-compose pull
$ docker-compose up -d

optionally change `PORTS` via `.env`:

$ FRONTEND=9000 BACKEND=9100 docker-compose up -d

1. Go to `http://localhost:8080` [Advanced](http://localhost:8080/@@plone-addsite?site_id=Plone&advanced=1):
* Add `Plone` site with add-ons enabled (**user:** `admin`, **password:** `admin`):
* `kitconcept.volto`

1. See application at http://localhost:8000

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)
* Within `Rancher > Catalog > EEA` deploy [Volto - IMS](https://github.com/eea/eea.rancher.catalog/tree/master/templates/volto-ims)

### 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/)
* Create a new release of this code via `git tag` command or [Draft new release](https://github.com/eea/ims-frontend/releases/new) on Github.
* A new Docker image is built and released automatically on [DockerHub](https://hub.docker.com/r/eeacms/ims-frontend) based on this tag.
* A new entry is automatically added to [Volto - IMS](https://github.com/eea/eea.rancher.catalog/tree/master/templates/volto-ims) `EEA Rancher Catalog`

### Upgrade

Expand Down
14 changes: 1 addition & 13 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
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',
};
};
module.exports = require('@plone/volto/babel');
Loading

0 comments on commit e5785d2

Please sign in to comment.