This setup is working for me:
- create a sub-domain from Plesk (ex. gitlab.mydomain.com)
- select your Let's Encrypt certificate in "Hosting Settings" and be sure to set a permanent 301 redirect on HTTPS (simply tick the checkbox)
- when starting your Docker container, expose port 80 (ex. 80:10080)
- in "Apache & nginx Settings" add the following:
location / {
proxy_pass http://localhost:10080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
This will serve your sub-domain through HTTPS and your Let's Encrypt certificate, while proxying requests to port 80 of your container so you don't have to bother about passing the certificate to GitLab from outside the container.
From my understanding this is safe, since un-encrypted traffic is confined in the server (if your Docker daemon is on the same server as Plesk) and unaccessible from the outside.
--
For your last point
beeing able to run build tasks in GitLab container (npm scripts etc.)
and finally move specific output files to directories of subdomains
managed by Plesk (outside of container)
that's a whole question by itself.
To run builds you'll need to install GitLab Runner. GitLab docs suggests to install it on a different host, but you may try using their Docker image on the same host.
For building and deploying your applications, see GitLab Runner docs. You will need to setup "pipelines" for what is called "Continuous Deployment".
To create a sub-domain for every app you could either:
- create the sub-domains manually from Plesk and deploying the files with scripting as the final step of your "pipeline" build
- use some scripting and Plesk API's to create sub-domains automatically
- ignore Plesk and go full Docker; use a reverse-proxy that will handle all your sub-domains and Let's Encrypt certificates, such as Traefik
These are just pointers, I suggest you to search and read more on the subject of CI/CD.