0
votes

My Sapper app deploys Ok if I build it first and then deploy it from my local machine with gcloud app deploy.

My app.yaml just has: runtime:nodejs10 in it to deploy to the standard environment.

Now I can't achieve the same when I try to use Gitlab CI to deploy on git push. In my .gitlab-ci.yml file I have 2 jobs: 1 to npm install and to run the build command and a second one to deploy to gcloud.

The 2 jobs complete but when I chack the version it has a 500 error and the logs say: Error: Cannot find module '/srv/__sapper__/build'.

So this has me going round in circles. I've tried moving svelte and sapper from dev deps to dependencies in package.json but it has not helped, I've looked at adding handlers in my app.yaml but am confused how, I've seen an issue on sapper github mentioning something related to svelte makefile and an issue with it needing to be built for the docker image to use it but no clear solution is proposed...

My .gitlab-ci.yml looks like this:

production-build:
  stage: build-for-prod
  image: node:10
  script:
    - npm install
    - npm run build
  only:
    - master 

prod-deploy:
    stage: production
    only:
      - master
    needs: ["production-build"]
    image: google/cloud-sdk:alpine
    environment: PROD
    script:
    - echo $SERVICE_ACCOUNT_KEY > /tmp/$CI_PIPELINE_ID.json
    - gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
    - gcloud --quiet --project sapper1-test app deploy app.yaml --verbosity debug --no-promote
    after_script:
    - rm /tmp/$CI_PIPELINE_ID.json
1

1 Answers

0
votes

Correct me if i'm wrong, but to me this looks like you've misconfigured it. The jobs are running in separate containers and deploy doesn't have access to build results, that's why it is missing dependencies.

Artifacts might help to pass the built libraries around. But i would just build a custom image containing both Nodejs and Cloud SDK and combined two jobs on top of this image.