#Open ports for gitlab-runner

30 messages · Page 1 of 1 (latest)

dim glade
#

I am running a website with a nodejs backend and I want to have it so that once it deploys it goes to port 5000. I have gotten it to deploy but I can't access the port. Btw the server only supports ipv6.

ruby arch
#

Are you running it inside CI/CD? I'm confused about the gitlab-runner comment 🙂

ruby arch
#

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

dim glade
#

I'm not sure if it's in a docker or not

ruby arch
#

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

dim glade
#

how can i find the name attribute?

ruby arch
dim glade
#

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
ruby arch
#

ok, it looks like it's not a service, there's no "service" keyword

#

is npm install running your server?

dim glade
#

No npm install runs installs the packages

#

and then forever app.js runs the script

#

in jobs i can see:

ruby arch
#

ok, so that's what's running it then?

dim glade
#

forever app.js is yes

ruby arch
#

So is a follow-up job attempting to connect to it then?

dim glade
#

there is only one job

ruby arch
#

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.

dim glade
#

oh

#

so how would i deploy it so it keeps running?

ruby arch
#

You need to find a hosting service (something like a public cloud provider, to host it on

dim glade
#

i already have the gitlab-runner so that it runs on a vps i bought

ruby arch
#

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

dim glade
#

is there anyway I can automate this using gitlab?

#

so that if i push to my main branch if autodeploys to the vps

ruby arch
#

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