#Open ports for gitlab-runner
30 messages · Page 1 of 1 (latest)
Are you running it inside CI/CD? I'm confused about the gitlab-runner comment 🙂
Yes I am
Are you running the website within the CI/CD runner? If so, is it a docker container or something? even with IPv6, localhost:5000 should hit your local run
I'm not sure if it's in a docker or not
OK, you'll want to figure out how the server is being deployed. If you can't access it on localhost:5000, it's likely running as a service in the CI/CD pipeline. If it is, check out the name attribute of that service, and you should be able to access it using the <name>:5000 DNS entry. For example, if the name of the service is myservicename, you'd access it at myservicename:5000
how can i find the name attribute?
check out the name attribute here: https://docs.gitlab.com/ee/ci/yaml/#services
This is my .gitlab-ci.yml
Where would I put the alias or name attribute exactly?
- deploy
deploy:
stage: deploy
script:
- npm install
- echo <password> | sudo -S forever app.js
image: npm:latest
ok, it looks like it's not a service, there's no "service" keyword
is npm install running your server?
No npm install runs installs the packages
and then forever app.js runs the script
in jobs i can see:
ok, so that's what's running it then?
forever app.js is yes
So is a follow-up job attempting to connect to it then?
there is only one job
got it - so what do you mean when you "deploy" then? It looks like you're just running the site within the context of the CI/CD job. As soon as the job ends, the site will be shut down and go offline.
You need to find a hosting service (something like a public cloud provider, to host it on
i already have the gitlab-runner so that it runs on a vps i bought
OK, if you've bought a VPS already, you can have your job push your app.js package to the VPS, then you can start it on your VPS
is there anyway I can automate this using gitlab?
so that if i push to my main branch if autodeploys to the vps
yes, of course. The easiest way is to treat your VPS as a remote server, and have your gitlab job use something like SCP to upload the app.js, then SSH into your VPS and start the app.js package
You would want to have it run "headless", so that when your SSH session disconnected, it didn't stop the process
Something like "nohup" tends to be good for this
I would recommend figuring out how to do it manually first, then you can mimic the steps needed in your CI job