0

Setup:

1 GIT repository which contains client/server/shared code, currently on 1 branch.

Build process:

  • The client is a web-based application and needs to be minimized/bundled/etc, which results in one file
  • The server remains the same for now, although it might be bundled later on

Problem:

I do not want all files to be on my production server, just the bundled version of the client and the server folder. If I would pull the master branch in, I get all files and not just the bundled version.

Solution:

??? - How do I have to handle this? Create additional repository, create multiple branches? How is this typically done?

Captain Obvious
  • 745
  • 3
  • 17
  • 39

2 Answers2

3

Typically you would like to separate your Source Control, build process and deployable artifacts. Git is primarily for Source Control, the accepted practice is to only have source code in it.

Then you would have it built with some build tool (Jenkins, bamboo etc.) Then you can either use the build result from the build tool, or if you prefer use a version control for your artifacts like Nexus or artifactory.

This may sound complicated, but does avoid a lot of problems in future.

dubes
  • 5,324
  • 3
  • 34
  • 47
  • Agree. You actually talking about the deployment process where you move your code from development to production – ItayB Nov 22 '16 at 20:29
  • Anything specific for web applications? I'm using node.js for server and webpack for client-side javascript at the moment. Currently looking into, which might answer my question eventually: http://stackoverflow.com/questions/35054082/webpack-how-to-build-production-code-and-how-to-use-it – Captain Obvious Nov 22 '16 at 20:31
  • Cannot comment from experience, but the following [answer](http://stackoverflow.com/questions/21259181/how-to-package-deploy-node-js-express-web-application) seems to be saying on downloading all files. However the following [article](https://strongloop.com/strongblog/node-js-deploy-production-best-practice/) seems also to make sense (coming from a java background) – dubes Nov 22 '16 at 20:34
  • Thanks, i'm going to accept this answer and dive deeper into the building process. – Captain Obvious Nov 22 '16 at 20:37
  • glad to be of help :-) – dubes Nov 22 '16 at 20:38
0

You can use .gitattributes (5) export-ignore directive to select files which are in your version control, but you don't need on production.

If you use a deployment system like Capistrano 3 it will actually use git-archive (1). This command would create an archive to be deployed in the release folder and it will abide the export-ignore rules in your .gitattributes file.


For your client file, you can bundle the file locally or on the machine where you deploy and then rsync it or upload it any other way to the release folder on the production machine before activating the new release.

I can also recommend that you actually deploy your client file to a CDN and the server would just serve an HTML page with a versioned client from your CDN.

Haralan Dobrev
  • 7,617
  • 2
  • 48
  • 66