Jenkins Stack architecture: docker vs server

Hi! We are trying to build a deploy job with jenkins on a already existing architecture and we have got this requirements:

  • We can’t install jenkins on the same server of the project:
  • With jenkins we should run php command, php script, git merge.

I tried jenkins on a docker image but it was missing of php and the other dependecies that we need. So i thought to build a Dockerfile adding all the dependencies that we need but i think that we could have problem with users/roles and permission.

So i thought that it could be possible to create a stack directly on a cloud ubuntu and add all the dependencies there with a clean installation of jenkins.

How do you manage your stack in production environment? Is there any best practices on the architecture?
Could the server solution be a correct way to manage our problem?


I wouldn’t recommend putting jenkins on your production servers. It would be an attack vector to have unnecessary apps running in production

There are many many many tools out there to do deployments. Honestly I think the easiest way is to ssh

In pipeline, assuming a linux host

steps {
    sshagent(credentials: ['ssh-credentials-id']) {
      sh('ssh $PRODUCTION "docker pull $imagename && docker restart $containername" // or something

or you can ssh in and git fetch and then checkout a different branch
or scp all the files you care about

There’s really no right way to do it.

1 Like

Thanks you so much. We’ll move jenkins on another server and use the login command.

1 Like

Hello and welcome to this community @francesco-di-marcant :wave:

Your first idea of building a docker image of your own for a Jenkins agent sounds good to me, that’s one of the reasons why the docker-agent image exists.
For my needs, I start with the docker-ssh-agent, but you could very well start from the docker-agent.