Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Strapi in production and version control sync issues

I'm wondering what the best practice is for running Strapi in production. I noticed that Strapi generates new files when a content type is added. This means that the production environment's files will become out of sync with version control. Is there a recommended deployment process? Am I supposed to commit changes from production to my git repo after making changes in the admin?

like image 958
greatwitenorth Avatar asked Sep 12 '18 20:09

greatwitenorth


People also ask

Is there a way to deploy a strapi project to production?

There are no known nor recommended workarounds for this. Strapi deployments are closely coupled with source control and we strongly recommend that you do development locally, push that code into staging with atomic test data, then if everything looks good you deploy that code in production. Thank you. Thats great information for a noob

Does strapi support model creation and updating in production environments?

At this time and in the future there is no plan to allow model creating or updating while in a production environment, and there is currently no plans to move model settings into the database. There are no known nor recommended workarounds for this. Does Strapi handle deploying or migrating of content?

Why does strapi generate new files when adding a content type?

I noticed that Strapi generates new files when a content type is added. This means that the production environment's files will become out of sync with version control. Is there a recommended deployment process?

What is the “flow” of development for strapi?

Generally your “flow” of development would follow the following path: Development - Develop your Strapi application locally on your host machine, then push changes into source control Staging - Deploy changes from source control to a “production-like” environment for testing Production - If no other changes are needed, deploy into production


1 Answers

The file generation which is made primarily by content-type-builder and other settings are disabled in production mode NODE_ENV=production

The admin panel is supposed to be already built on prod, so you only add necessary data into DB based on the given data structure.

TLTR:

Summarizing answer to your question in from github.com/strapi/strapi/issues/1986:


emadicio commented on 20 Sep 2018

If you run your app with NODE_ENV=production you'll notice that plugins that actually edit or create files are disabled. So that means you cannot create or edit content types in prod


Downloaddave commented on 22 Sep 2018:

I had deployed Strapi locally then to a Prod environment, and was confused since I didn't see the content-type-builder in the production CMS.

I'm trying to understand the deployment and update process as well...

  • Developer sets Strapi up locally
  • Creates content-types using the content-type-builder
  • Strapi makes updates to the file structure locally and on the local MongoDB
  • On production we will have to push both the code and db updates?

I understand that making changes to the content-type-builder reboots the service, and we don't want production to go down during the rebuild, but it seems like data would get really out of sync between production and development.


Aurelsicoko commented on 2 Oct 2018

You're right! The Content-Type Builder is a development plugin. His goal is to speed up the development of your project. It should not be used in production. We didn't design this plugin like for this usage.

The real pain is to migrate the development configuration to production, and vice-versa. We plan to offer a new command with the CLI called strapi migrate to easily migrate from an environment to another. I can't give you a release date though...

like image 136
Maksym Avatar answered Nov 16 '22 00:11

Maksym