Gitlab page for node express

Hi, I’m trying to create a page using node and express js. Here’s what I have done so far https://gitlab.com/isemaj/fcc-timestamp-microservice. Here’s my .gitlab-ci.yml

image: node:8.12.0-jessie

before_script:
  - node -v
  - npm -v

stages:
  - prep
  - build 
  - deploy

prep:
  stage: prep
  script: 
    - npm install 
  artifacts:
    paths:
      - node_modules
  cache:
    paths:
      - node_modules

build:
  stage: build
  script:
    - npm run deploy
  artifacts:
    paths:
      - public

pages:
  stage: deploy
  artifacts:
    paths:
      - public
  only:
    - master

I encountered two problems. First on my pages job I don’t have the script part which is necessary but I don’t know what should I put there since on my build job I already run the npm run deploy. The other one is that I’m pretty sure that on my build's script part will get stuck on like Listening on port 4108 ... because when npm run deploy executed it will do the node server.js which is in my package.json which definitely listen on a certain port but that’s it, it will not continue to the pages job. I hope someone can help me. :slight_smile:

First of all, GitLab Pages only works with static files (HTML, CSS, JS).

For the pages job, just add an echo in your script:

script: echo ""

The build job must build the HTML files, so you must find a way to do that.

1 Like