0

I have a question about Strapi before start using it but couldn't find a answer.

Strapi cms makes changes on files after certain edits or when uploaded a media(adds media to folder).

Lets say I setted up Strapi and published it to production, on production when someone very normally uploads/changes a media and it creates those files in file system and of course shows up if you run git status in prod server.

So after that when I need to add something to dev branch and then when updating the prod it will have a conflict when I try to merge dev branch to prod. Commiting those images on prod and pulling all those to local are not logical. Am I not seeing something here that resolves this ? If only option is to use other media storage services then why even Strapi added something like this ?

WoOHooW
  • 42
  • 1
  • 6

1 Answers1

2

first off, it's not recommended to share environments (e.g. share database or media folder). However we all pretty much doing this.

So usually the public/uploads folder is added to .gitignore if it isn't for you seems someone removed it manually. There is also option to place uploads folder outside of directory:

// path: ./config/server.js
module.exports = ({ env }) => ({
  ...
  dirs: {
    public: '/var/storage/...`
  }
})

I can recommend:

  1. Add public/uploads folder to .gitignore
  2. Fix issue wit tracked files link
antokhio
  • 1,497
  • 2
  • 11
  • 16
  • Thanks, I was thinking storing uploads outside of app but didn't know how, gitignore might work too. Automatically uploads folder came with .gitkeep file so I didn't thought of gitignore. Btw can you explain what did you mean share environments. From the start I didn't understand how/where Strapi created database and connected it to that whats its limits etc., idk even if its secure. Is it recommended/needed or possible to change database Strapi automatically created ? – WoOHooW Dec 29 '22 at 11:51
  • 1
    Hi, well if you use SQLite, then the database is just a file, but I use Postgres, it a server you have to setup, same as MySQL. So if your dev server and prod are both connected to same database, it’s shared, then when you change something on dev, it changes on prod (dropping tables, removing props etc.) so it’s really important to be careful… – antokhio Dec 29 '22 at 14:16