Search code examples
gitlaraveldeploymentgulpweb-deployment

Right way to deploy project and compile assets


I save laravel project on github repo and when I have some changes in development I push it to the repo and then deploy it on production server in this way:

1) git pull
...
n) gulp --production

After a while the project's css/js start grow in size and compiling the assets start take about 30 sec. So I guess maybe I use not suit deployment process because after git pull command the project still use old assets and only after 30 sec it gets new static. Can you advise me right way how to deploy project to production server without delays. I have read a lot about this but couldn't find good solution.

  • Some people recomment to save compiled assets in repo: it's good because you don't need to install nodejs, gulp on production but there are a lot of minus to do so;
  • Also there exists different CI systems like jenkins,circleCI, Travis CI but I didn't use them before and I don't know if they can help to resolve the problem.

Solution

  • This is definitely the job of a CI/Build server or Saas product. We use Amazon Web Services for our products, so within their eco-system, we use the CodeBuild product to prepare our code for deployment to the environments.

    The source code goes into our CodePipeline, which then pushes it to CodeBuild which installs all our composer and node dependencies, it then runs the webpack build. Assume this all goes successfully it will compress the built files, and send them back up to CodePipeline, ready for the next step.

    We have also used Jenkins in the past but found this required a fair amount of complicated configuration and maintenance.