New World - Strapi - Part 1
The “New World” series finds its technical beginning here. In this article I will operate Strapi as a Docker container/stack.
What was Strapi again?
Strapi is a Headless CMS. That means: Strapi provides all requirements that apply to a backend. Data storage, web service, and administration are a few of these requirements.
The display of content etc. must be provided separately by the operator/developer. I will use GatsbyJS as an example.
What can Strapi do?
Ghost, for example, is a system that I have come to like very much. Ghost can also be operated as a Headless CMS. If Ghost offered the creation of custom “content types”, I wouldn’t write this post.
ContentTypes / Fields
With Strapi I can create custom content types. Various field types are also offered, with which the content type can be modeled.
The relationship/relations field is worth mentioning separately here. For someone who has been modeling content types for over 10 years – I can do SharePoint and I can do it pretty well – the lookup field was always such a half-finished thing. With MOSS 2007 it was cool, over the years not so much :)
The lookup field can today still do 1->1 or 1->n relations. Strapi can do more: besides 1->1 and 1->n, n->n is also possible… and then the whole inverse :)
GraphQL
Strapi can do GraphQL and it does it quite well! Strapi can in my opinion also be used for quick showcases or small to medium PoCs.
I model my (relational) data model at the surface, I assign the required permissions for the API via a surface and can then query/develop against it. That’s simple, simple :)
The Technological Stack
Strapi is written in Node.js. For me this part is actually very uninteresting, as I see languages and/or frameworks as tools that I should be able to use.
What is interesting, however: I can react programmatically at various points and e.g. adjust the service, controller, or model for a content type. The latter – Models – even offer the possibility to react to various events when managing entities. Something like with SharePoint ListEventReceivers. I love it :)
What Strapi Can’t Do
Strapi can’t do a lot of things OOTB, most of it can be implemented/integrated programmatically.
Admin Interface
What I don’t like so much is the admin interface. It’s better than some other Headless CMS systems, but still damn ugly. Try setting a date in a date field that is before 2012…
No ContentType Hierarchy
There are also functions that I’m used to from SharePoint and actually miss in Strapi: Hierarchical ContentType structure!
If Strapi offered something like that, it would be the ideal platform for me to build small ontologies and with a bit of logic build a semantic web environment.
Putting into Operation with External MongoDB
This undertaking is actually very simple since the makers of Strapi provide a Docker image and also fairly good documentation.
The corresponding docker-compose.yml:
version: '3'
services:
strapi:
container_name: strapi
image: strapi/strapi:${TAG}
environment:
- DATABASE_CLIENT=${DATABASE_CLIENT}
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_PORT=${DATABASE_PORT}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USERNAME=${DATABASE_USERNAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_AUTHENTICATION_DATABASE=${DATABASE_AUTHENTICATION_DATABASE}
- VIRTUAL_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
ports:
- 1337:1337
volumes:
- strapi_data:/srv/app
volumes:
strapi_data:
networks:
default:
external:
name: nginx-proxy
Start with docker-compose up and then you can start modeling.
How Will It Continue?
What will definitely follow at some point: A guide on how to set up Strapi as a local development environment via package manager, make adjustments, and build a Docker image… And how to (relatively easily) import the articles from Ghost.