Deploy using GIT on my server

4

Hello,

I use to be able to upload my GIT site files, deploy to my server automatically so I did the following:

1 - I created a GIT repository on my server, outside the public_html folder 2 - then created a post-receive file inside the hooks directory of my repository, where it deploy to my server, with the following line

GIT_WORK_TREE=/home/diretorio/public_html git checkout -f

But I have some problems and I do not know how to solve, they are:

Image files

  • I have a directory of user images in assets / img / users /, the problem is that every time I do a PULL to my repository on my server this directory is "zeroed" since the files that are on the server do not are on my machine
  

Question:

  • How do I prevent this directory from being updated in deploy? already tried to use .gitignore but did not work

Certain directories can not be in deploy

  • At my place of work I have a GIT server too, where we make all the PULL of our applications for other developers to work on, so all our projects have all the files we work with, including the database diagram file
  • This diagram file is in the / sql / diagram-name folder that is inside my project structure
  • When I do a PULL to our internal GIT server this folder has to be sent normally because it is a working file that another developer can use, but when I do the PULL to the production server, it automatically performs the DEPLOY this folder can not be sent to DEPLOY
  

Question

  • How can I make sure that the / sql folder when performing PULL for the production server is not included in the DEPLOY action and then copied to the web server?
  • I've tried using the GIT command --exclude = / home / directory / folder but it does not work

Who can help me and give me a light?

Thank you

    
asked by anonymous 17.06.2017 / 00:15

1 answer

0

Jorge,

What you are doing is automating your deploy process, or pipeline automation; but Git is not the right tool for this. I mean, it is one of the tools that are part of the process, but it is not through it that you will be able to fulfill all of your needs!

  • First you build, that is, it's basically the build process, but it also involves other sub-processes. So if you are using a non-compilable language, you will still have a build step, which will do for example: packaging, miniminating javascript, etc ...
  • Then there is the deploy process itself, where you would perform, for example, replacing environment variables, or the connection string with database.
  • Tools that will help: make, cake, Gulp, ... Then just write scripts to automate the process. As you did not give more information about language, platform, etc ... I can not direct you to any of them.

        
    17.06.2017 / 08:41