Weblog
How to deploy Volto sites automatically in non-docker scenarios
Talk by Mikel Larreategi at the Plone Conference 2022 in Namur.
We are not in the docker-world yet, at least not for deploying sites. Last year we had to publish several Volto sites in production and needed some automated way to handle those deployments because Volto's build process takes so time. We have manged to build a CI-CD pipeline using Gitlab-CI and several other tools to release, build and publish volto addons and sites in an automated way. Earlier this year we published a blog-post explaining this process and this talk will be the extended version of the blog-post.
Why are we not using Docker? We are migrating Plone 4.3 to 5.2. We use DigitalOcean standard droplets. We are used to Buildout. These are not Docker deployments. We are starting some Volto developments, and did not want to change our standard deployment yet.
Running yarn build
on the server took half an hour, and then broke, so that was not a solution. We had to upgrade the server to run the build.
The solution was to automate the process. Automate add-on package creation, frontend package compilation.
Problem: we are using private repositories, so could not use the public npmjs registry for packages. Do something private? This is not that easy.
Verdaccio to the rescue. This is a private npm repository, which proxies to the real npmjs for public packages. We configured this to work only in authenticated mode. We needed to configure npm and yarn to use authentication.
We setup a pipeline in GitLab. When a pull request of a Volto add-on is merged, a package is created and published. When a pull request for the front end is merged, the frontend is built and copied to the server with scp and then a supervisor restart. When finished an e-mail is sent through MailJet api.
GitLab CI configuration is hard. You have stages, steps, artefacts. Artefacts are shared beween jobs, but not between pipelines. Use artefacts to cache already built things. Use variables for everything. We share configuration in a GitHub repos and sync it to other repos with a Python script.
Links to the configuration can be seen at labur.eus/deploy-volto.
State of the Plone Community
Keynote on Wednesday at the Plone Conference 2022 by Erico Andrei.
Thank you Imio and Affinitic for organising this conference. Special thanks to Martin Peeters and Joël Lambillotte who lead these companies.
Plone is multiple things:
- a product and api
- a community
- a foundation (organisation)
For the first part, our four release managers will talk about it in the keynote on Friday. As Plone Foundation president I will talk about the first and second parts.
The Plone community is global, online, open source, multilingual. We started as an online community: Alan Runyan and Alex Limi started Plone by talking on IRC, which is how old people like me used to communicate.
A good part of Plone is that we are truly open source and free. There is no big company behind it that can remove parts of the software or suddenly start asking money for it.
Plone started from the Zope community. Other communities came from Plone, like Guillotina, with people still here at the conference today.
In my home country of Brazil, the Plone community was started before the Python community. The first seven Python conferences in Brazil were organised by the Plone community.
I was welcomed into the global Plone community by people like Jens and Hanno, which was impressive to me. But mostly I thought: hey, these are nice, normal people, that you can talk to.
The community will embrace you. The community will help you overcome your fears, like I had of running for the Plone board.
I had two role models: Dorneless Treméa and Jean Ferri. They left us way too early in life. What I learned:
- Lead by example. No one wants to organise a conference? Let's do it.
- Be generous with your time.
- Help people.
How can you help when you are not a developer, but a user?
- Ask questions on community.plone.org.
- Help with documentation. Thank you Katja Süss and Steve Piercy for doing a lot of work here. I am nervous when I add documentation because English is not my native language. Don't worry, Steve will fix it for you.
- Translate Plone in your language.
- Make designs for Plone. Maybe a nice photo to go with a news item.
- Share your experience.
- Work with issues, do code review. The past week or so, on every issue or pull request in Plone, there was a comment from either David Glick, Alessandro Pisa or Wesley Barroso.
- Spread the word, like Rikupekka Oksanen.
- We had Google Summer of Code students this year: Bhutan R J, Avi Mishra, Md Sahil, Robot Singh, helped by Eric Brehault and others.
Plone Foundation
The Plone Foundation is an organisation that supports the community. We promote and protect Plone. We are the legal shield for threats, or preventing companies taking over Plone, or saying they are the largest. We support community meetings and sprints. We had the World Plone Day, with lots of video content.
If you want to organise a sprint or a meeting in your region, talk to us. We can help with money or with organisation.
We had ten new Foundation members the last twelve months. I know most people here who are no members have imposter syndrome: I am not good enough. That is not true. That you are here is proof enough. Nominate yourself.
You can sponsor Plone.
Please consider joining the Plone board.
We are a diverse community. If your English is bad, you are still welcome in our community. We don't have enough women here, or people from the south of the planet.
We need to generate more content. Do a podcast, a video, a success story. In your language.
We need more events. They don't have to be big. Just a local meetup. We need to present the software and the community in other places, like Pycon or React conferences. We are going to have a new version of the Plone Symposium in Brazil, on November 18, 2022.
World Plone day will be April 26, 2023. It is great if you organise a local meeting that day.
I see that a lot of people are here at a Plone conference for the first time. There are young people here. People leave the community, others join, some come back after a while. The Plone community stays with you even after you leave.
David Ichim: What's new in Plone 6 frontend for developers
Talk by David Ichim at the online Plone Conference 2021.
Distilled from the latest work done in Volto, we're showcasing some patterns, features, or enhancements that have landed in Volto from the last year to the present. We will also have a glimpse of what is ahead in the future of Volto with the new features roadmap.
In the past year we had four major releases, 40 minor releases, 36 alpha releases, 25 patch releases, for a total of 105 releases. Plus some new tooling and tool releases, like plone i18n and plone generator.
New Volto config, dubbed as Volto's Configuration Registry, introduced to fix circular import dependency problems. Hot Module Reloader was fixed. Read the upgrade guide.
New i18n (internationalisation) infrastructure. This is now a separate package. Same is used for generation of i18n in add-ons.Read the upgrade guide.
Forms as schema. Forms should be constructed from schemas instead of by hand. InlineForm allows us to create forms for blocks from a schema. Blocks can have variations, or we can extend it. Read the edit component documentation.
New widgets:
- Object List Widget. Similar to the original DataGridField. Used in core by the Search Block facets.
- Object Browser Widget is now a separate widget, instead of part of a block, and now allows the addition of external content.
- Querystring Widget. Behaves like its counterpart from plone.app.querystring. Allows to create search criteria, used by the search block.
- URL Widget. Used on text inputs, it knows to validate their value as a url, both internal and external.
- Vocabulary Terms Widget for a JSONField, acts as a source for a SimpleVocabulary or Choice field. Play with it in the storybook.
New core blocks:
- Search block
- Teaser block (ongoing work).
Pluggable framework, similar to React's Portal component. See the talk by Tiberiu and see the Pluggables development recipe.
Storybook provides a sandbox to build and test visual components in isolation. Currently it is only setup to be used by Volto core. We need help with work to have storybook setup with adding. See the Storybook talk held by Victor, and see the storybook itself.
Critical CSS: inline the critical CSS for improved performance. Run critical-cli to output critical.css. This is then inlined in the headers, while regular CSS is moved to the bottom of the body. See the deployment documentation.
Lazy Loading utilities. Introduced injectLazyLibs HOC wrapper to inject lazy-loaded libraries as properties to your components. These components are only loaded once all your main libs are loaded.
Express.js middleware. Volto uses this for SSR and static resources serving. You can now write custom middleware and add it to settings.expressMiddleware
.
API expanders allow the expansion of different API endpoints from Volto with calls from your custom endpoints. Avoid adding too many expanders if they are not critical to the initial page.
External routes: useful when another application is published under the same top domain as Volto. If Volto would fetch the content for that path, it will break. You can disable this path in config.settings.externalRoutes
. You can also use regular expressions.
Seamless mode, introduced in Volto 13, enhanced in Volto 14, which has already seen a lot of alpha releases. Originally, we tried to unify both frontend and backend servers under the same path, but this was tricky, causing various problems. We settled on a new ++api++
traversal for getting information from the backend. Also, to come closer to zero config, you can now pass environment variables at runtime instead of build time. This means you can generate one build, and use this in all environments (testing, production). Read the deployment documentation.
Context navigation component. This is a navigation portlet component, similar to Classic Plone. The view is there, but you need to enable it. See the development recipe.
There is some work in progress:
- Slots are Volto's answer to portlets, see the Volto Slots talk by Tiberiu Ichim for more details.
- Image proxy: image scale generation done by a middleware instead of plone.scale.
- Authentication from backend.
- Replace Draft.js editor with Volto Slate. What is missing is a migration tool from one to the other. But work has started on a block conversion tool.
- Async blocks that work with SSR.
- Defaults in blocks form.
Future work:
- Defaults in all widgets
- Enable blocks enhancers in all blocks
- Storybook in add-ons
- Use newest react-intl package
- Refactor the folder contents component
- Form editing text enhancements, making it easier to modify text inputs.
- A "group block" included with Volto
- Quanta toolbar
I did nothing, I just brag about what others have done. So thank you Volto early adopter community!
Tiberiu Ichim: Volto Pluggables
Talk by Tiberiu Ichim at the online Plone Conference 2021.
This presentation is an introduction to the new Volto developer-targeted feature, the Pluggables framework. It is more an argument for extensibility in CMS UI and in Volto.
Basically, with Pluggable a central component provides a pluggable slot that other components can fill, like this:
<div className="toolbar">
<Pluggable name="toolbar-main" />
</div>
// ...
<Plug id="quicklinks" pluggable="toobar-main">
<Button />
</Plug>
This is a Volto port of https://github.com/robik/react-view-slot.
The big picture:
- I work with Eaudeweb Romania
- Our client EEA is an early adopter of Volto
- The strategy is: move everything to Volto
- But the EEA sites are less brochure, the CMS side is really strong.
- We build powerful UIs for power users.
- The EEA already has 91 Volto repositories on GitHub. How can we scale that? Can we write an add-on to make it easier to write an add-on?
In React, data flow is top to bottom. A parent component passes properties to children and children communicate with the parent by emitting events. This makes sense and works well. For "out of tree" data you need Redux. There is no protocol for add-hoc communication between components.
UI state is fluid. Extensibility means reusability and scalability. This is hard. You need to design upfront. Plone backend uses the Zope Component Architecture, which means pluggability is baked in, it is very natural. You can view Pluggables as viewlets-on-demand, but they are really not. But yes, you can think about a Pluggable as a viewletmanager and a Plug as a viewlet.
You can overwrite a Plug with a Plug, by registering it with the same id. So if the original Plug gives you color blue, you can overwrite it with color red.
You can do custom rendering of Plugs within your Pluggable, by iterating over all Plugs and for example wrapping each in a div with a class name.
Showcase: volto-workflow-progress
(main toolbar plugin) and volto-editing-progress
("sidebar" for plugin).
Limitations:
- No Server Side Rendering
- Watch out for dependency lists.
- Limited adoption for now.
Implementation in pseudocode:
First the context:
<PluggablesProvider>
<Pluggable name="top" />
<Plug name="delete" />
</PluggablesProvider>
Then the dumb version of the Plug:
const Plug = ({id, children}) => {
const { register } = useContext(PluggablesProvider.Context);
React.useEffect(() => {
register(id, () => children);
});
return null;
}
Takes a bit of study, but in the end it is not so hard.
The Pluggable becomes a bit simpler:
const Pluggable = (name) => {
const { getPlugs } => useContext(PluggablesProvider.Context);
return getPlugs(name).map(f => f());
}
Eric Bréhault: AbFab! Come back to easy frontend development
Talk by Eric Bréhault at the online Plone Conference 2021.
My talk from last year, presented on a T-shirt, was about second-guessing the SPA pattern, or Single Page App. After this year's introduction with T-shirts, I come again with a T-shirt thing, showing: AbFab: Absolutely Fabulous. It refers to the comic show from the nineties. British humor was always an inspiration for the Plone community. Or is it Spanish? Ab fab, away from the factory.
In the zeroes, the question was: why do I use 5 different jQuery versions on my page?
In the tens: why 5 different JS frameworks?
In the twenties it is just: WHYYYYY?
If you don't have the most recent problem, you are a big loser.
What if I want something simpler? Back in the nineties you had good British TV shows, and easy web development. HTML is still fabulous. HTML contains content.
Components are contents too, which is good. JS frameworks use this a lot. Idea of AbFab: push this to the backend.
Use a tree of components and subcomponents, like a filesystem with folders.
You request /polls/poll1
.
You get HTML, json, a few components.
You then request /polls/poll2
.
You have the HTML already, so you just needs the json, and we already have most components, so we only need for example one extra.
Updated component: serve a new version, and all pages will use it.
You have no bundles. You just serve separate components, which are dynamically loaded as dependencies.
Your browser can do that.
Low code.
I use Svelte for this. In the basis, you simply write HTML. <h1>Hello world!</h1>
is a valid Svelte component. In React or Angular it is harder. In Svelte, if you need css, use a <style>
tag. Need javascript? Use a <script>
tag. To use another component:
<script>
import Hello from `./hello.svelte`;
</script>
<Hello></Hello>
So what is AbFab doing?
A component is stored in Guillotina, together with a compiled version.
Data in Guillotina is linked to a component.
Ask for the data, you get the needed components.
It will be tons of requests, but they will be small, and via HTTP/2 this goes quite fast.
We are using Guillotina at its finest, good for storing lots of small things in a hierarchy.
Low deployment.
My way to make it simple: Docker.
Low build.
I don't want npm installed, or webpack. At some point you do need it. I know this guy who edits CSS on GitHub, then has to wait 30 minutes for it to deploy, because it is too painful to build on his laptop. How to do this? Through The Web. Yes, it is naughtly, maybe forbidden, but I like it: the ability to change yourself.
I am 47 and have to accept who I am.
I am Eric.
I like Through-The-Web-shit.
The core of AbFab is about 200 lines. The editor is bigger.
Using an IDE is fine too. You can sync with the database. I make sure that the code I do is consistent with the documentation I am writing.
What is it good at? Small applications, like we would have done with Plomino previously. To be honest, for now I just made this for fun, so I don't care what it is good at.
Is it totally stupid? I made some disputable choices there. But it is about 200 lines frontend, 300 backend, so it can't be that bad.