Deploy Strapi and MongoDB to a server - reactjs

We have no clue about deployment of a react app that is currently running with strapi and a mongoDB.
The Problem is that me and my colleague can't see each others changes in the DB without importing the data files manually everytime.
We would like to be able to access the Strapi CMS from our server and store all the data in a shared DB. That way the customer does not need to open the code whenever he wants to change something.
We would like to avoid heroku and aws and deploy it on our own server.
Where should we start?
ps. We are Frontend guys!

For the database, you can use MongoDB Atlas.
Like this, you can have one database (hosted) for your development environment.
Here how to start with Strapi + MongoDB Atlas - https://strapi.io/documentation/3.0.0-beta.x/guides/databases.html#mongodb-installation

Related

Is there a way to backup/export & import Strapi data

So I am at the place where I lost all of my Strapi data after moving from local to remote host and deploying my Strapi through herokuapp.com
I am using Strapi in my personal NEXT.JS project.
Luckily my Strapi database wasn't so huge and all content-types were kept so I was able to recreate the database quite quick. Also this was just a personal project.
I am wondering though, if I decide to push Strapi to use in in more professional context and in real project – how do I move from local development to deployment without loosing all data?
Is there a way to export everything before deployment and then import it into the deployed CMS or how does this work?
Also – what if I want to do it the other way around? I will keep working on my app using my Strapi on Heroku but at some point I will want to replicate the CMS locally. Where is the data stored and how do it get access to it?
From docs: "Strapi does not currently provide any tools for migrating or deploying your data changes between different environments (ie. from development to production). With the exception being the Content-Manager settings"
And there is no export/import content for now.
To export your data for example from the local environment to the production you have to handle:
content-types - Strapi store this stuff at files so version control will help
database data - you have to make database backup manually and then import data at the production server
static files - if you use Srapi to handle the static files you probably will have to copy them manually and import them to the production server or use version control for it (bad option). They are stored at app/public/uploads
I didn't tried this myself but it looks like a pretty tough task.
Conclusion: if it's OK for you to migrate only your content types, just put a git on your Strapi folder
You can do it via the CLI now, new from version 4.6.
Strapi supports export, import, and transfer.
To create a tar of your data:
npm run strapi export --file my-strapi-export
To import data into your project:
npm run strapi import -f export_file.tar.gz
There are more options in the docs:
https://docs.strapi.io/developer-docs/latest/developer-resources/data-management.html#export-data-using-the-cli-tool
With the new data export & import system, you can backup & restore
your Strapi project data without acting manually and directly into the
database.
More info: https://strapi.io/blog/announcing-strapi-v4.6
Keep in mind Heroku is in the middle of shutting down its free tier, so using another provider like railway.app or render.com might be a good idea.
Anyway: As Eugene already mentioned in his answer there are 3 types of data that might have to transmitted (content types, the actual database, and files).
After your first deployment to Heroku you should end up with all content types being there, but with an empty database and no files.
Following this guide you will create an own database while setting up your project where you can now either export and import your database from your local development environment (which you would have to do manually) or put in new data by hand. Sometimes this is even better since development environments tend to include a lot of "Lorem Ipsum" content for testing purposes.
Future deployments should not reset your database though but keep your data from that environment.
Finally there are the files which I would recommend to store on Cloudinary since it's free, and Strapi offers an easy-to-use plugin for it. Just create a free account on Cloudinary, install the plugin in your Strapi project, and set your ENV variables for your production environment within Heroku.
I found this
Apparently they recently did a plugin tutorial that had to do with this issue. There is a plugin called strapi-plugin-import-export-content on git hub that might be able to help your issue.
git hub link

1st - How does Heroku interact with a database (sqlite) 2nd - How can I obtain the version of database that is on Heroku?

I had a very hard time trying to find solutions to this problem online, probably because I do not know how to phrase this weird problem. I also could not reach out to Heroku as their support team only serves paid customers. I would really appreciate help from anyone.
Some context:
I have recently started experimenting with Heroku and deployed my first web app (Python, Flask, SQLite3) via GitHub. It works as intended, I am even able to interact with my database (add/delete/update). However, after making an update to my code locally and pushing it to GitHub, I realised that when my web app got built again by Heroku with the updates, the changes I made to the SQLite database is reverted back the initial, local version. (aka I lost the updates I made during testing).
So here comes the first question:
How does Heroku actually interact with the database? Does it create a copy of all my code from GitHub and runs it locally on their servers? (Since no changes to the database are reflected in my GitHub Repo despite successful updates to the database values through the web app).
And if so, this is the second question:
Is there any way for me to get this "updated version" of my database from Heroku side so I can download it locally before I make and push any updates to my code, so as not to erase all the updates to the database that a user might have made through the web app?

How to deploy a simple json-server?

I completed an online React course and deployed my application to Heroku. During development, I used the 'json-server' module found at https://github.com/typicode/json-server. This served up a folder on my computer which contained a simple json file and a few images for my website while conforming with the REST API. What do I need to do to get the server to operate independently of my machine so that my application can fetch the data ? I have zero experience doing this.
if you mean you want to create a server for your site,
first of all, you need to get a server, which can run nodejs , then you need to deploy and run your JSON server via a nodejs(express) app.
then you can connect to your server via your website/app
in order to do these things, you can follow tutorials
there are lots of tutorials about it.
hope you got the idea.

React Folder Structure Questions

I'm currently trying to make a turn-based game for a class project using gameboard.io. My biggest issue is I don't know how to set up my folder structure with react and MongoDB as its a new technology I've been using.
I've tried a couple of different things but every time I try to use mongoDB I get loads of errors and files missing/not connecting and I'm sure my folder structure is broken.
Can anyone help me with an outline for a folder structure using those technologies? I know this isn't a typical question but I've been struggling with this. Any help would be appreciated, thank you.
Normally mongoDB runs on the back-end. Your front-end application would interact with mongo through an api. If you want to use a node.js powered back-end server application, express is a popular choice, but there are many others ( koa, hapi, Meteor, ...to name a few).
Then install mongoDB on (not the npm package but the server application, the npm package is the mongoDB driver that you use in your application to connect to the database, you will find instructions on mongoDB's website), I would also recommend installing mongoose, it's an object data modeling library.
If I where you, start with installing express, and work on communicating with express from your react app. Then install mongo/mongoose, and give it a try.

Export from AppEngine database to the local development database?

Is there a way to export the data on my AppEngine database to the development server (for testing purposes etc.) ?
Yes! Check out Google's "Uploading and Downloading Data"
If you'd like to test how your data
works with the app before uploading
it, you can load it into the
development server. Use the --url
option to point the tool at the
development server URL. For example:
appcfg.py upload_data --config_file=album_loader.py --filename=album_data.csv --kind=Album --url=http://localhost:8080/remote_api <app-directory>
The subsection on uploading and downloading all data is also worth looking at.
Not yet it seems
Of course you can go pulling the data yourself, one batch at a time...
Yes we can download all data from google app engine and can upload to datastore but sometimes uploading data to local development server is painfull because of errors. App Engine SDK versioning diffrences occurs this like problems. For example i developed an app 1 year ago. Today, i want update it. I downloaded all data from Google App Engine real servers. But i can't upload its to local development server. You know, we using EntityLoader class for this operation. Entity Class importing db module, but SDK throws, "no module named by db".
I suggest for App Engine lovers that; save your first test data for future. Don't think that i will download all datum for testing future. Save your own test data with Sqlite support. And save your deveopment enviromenment version for future. SDK Version updating sometimes causing painfully times for developers

Resources