An out-of-the-box configuration for jenkins deployment.
create a docker compose file like:
version: '3.8'
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
ports:
- "7082:8080"
- "50000:50000"
volumes:
- ./jenkins_home:/var/jenkins_home
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
the extra_host field is important so you can access the host machine from the container
create an nginx config file like
server {
server_name jenkins.torregrosa.dev;
location / {
proxy_pass http://localhost:7082;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
install the plugin *Publish over SSH* and configure the host and the ssh-key

create the project/ task as a free style and pick *Send files or execute commands over SSH *, with the host and commands for the deploy
