I've been battling with deploying (mainly PHP) websites as .deb files for some time and wonder if there's a better way than my rather convoluted method. My goal is continuous integration on my staging server and one-click deploys to the live server from within Jenkins.
My use case now:
- Developing code on OSX
- Version control in Git
- Source contains debian/ folder with control, postinst and prerm scripts
- Phing build script run locally in a fakeroot environment
- copies files into a /tmp build folder mirroring the filesystem layout
- sets up file ownership as root / www-data as appropriate
- runs dpkg-deb --build ${build.dir} ${working.dir}
- copies package to private deb repository on my LAN
I have tried to set up a Jenkins CI server to watch the Git repo for commits and automatically perform a build. The problem is that Jenkins runs as its own user who does not have permission to set the file permissions as above. I also can't see an obvious way to run the Phing build in a fakeroot environment from within Jenkins.
My questions are:
- Is there a better way to set up the correct file ownership and permissions rather than having to copy everything to a temporary dir and have a Phing step to chmod everything?
- Does the dpkg-deb command really need all the file permissions set up on the filesystem beforehand? Is there something that I could put in the debian/ folder that would set up these permissions when the .deb is installed?
- How can I get Jenkins to run a build script that has the correct rights to set up file ownership?
I may have misunderstood how .debs work but it seems rather inconvenient that the file ownership on your local filesystem source code has to mirror the destination!
I'm open to suggestions on any other build and CI systems that people use to perform a similar task.