Deploy using GIT on my server

Asked

Viewed 412 times

5

Hello,

I use it to upload my files from the GIT site, deploying 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 I created a post-receive file inside the Hooks directory of my repository, where it deploys to my server, with the following line

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

But I have some problems and I don’t know how to solve, it’s them:

Image files

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

Question:

  • how to make this directory not be updated in deploy? I tried using . gitignore but it didn’t work

Certain directories cannot be on the deploy

  • At my workplace I have a GIT server too, where we do all the PULL of our applications for other developers to work on, so all of 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 within my project structure
  • When I pull to our internal GIT server this folder has to be sent normally because it’s a working file that another developer can use, but when I pull to the production server, that automatically deploys this folder cannot be sent to DEPLOY

Question

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

Who can help me and give me a light would appreciate

Thank you

1 answer

1


Jorge,

What you’re doing is automating your deploy process, or Automation pipeline; but Git is not the right tool for it. 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 perform all these your needs!

  1. First you build a build, that is, basically it is the compilation process, but it also involves other sub-processes. So if you are using a noncompilable language, you will still have a build step, which will do for example: packaging, javascript minification, etc...
  2. Then there is the proper deployment process, where you would run, for example, replacement of environment variables, or the database connection string.

Tools you have will help: make, cake, Gulp, ... Then just write scripts to automate the process. As you have not given more information on language, platform, etc... I can not direct you to any of them.

  • 1

    Hello Gomes, first thank you for the reply, today I am using Codeigniter for development, all my platform is developed with this framework and Mysql database. Today I do not have this deployment process that quotes to mimic the files, replace variables, etc we do it by hand when uploading the files to the server, Being quite honest, I’m not sure how to set up this flow in a correct way and that can be easily replicated for the team and for new projects, could you give me some tips or indicate some ways to do this. Thank you

  • 1

    Gomes, I did some research on GULP, I found it very interesting, I’m already studying and did some tests, but it still doesn’t solve my deployment problem without doing FTP. I used the Gulp-deploy-git plugin compiling all the files to a folder and deploying it on the server but it didn’t work properly, you would have more or less a hint of how to maintain a more favorable environment, I think we’re kind of lost

Browser other questions tagged

You are not signed in. Login or sign up in order to post.