Unable to deploy Keystone JS app to Azure app service

Open
#9,070 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
azure, github-actions, nodejs, typescript
Domain
cloud, devops

Research direction

Review the inline GitHub Actions workflow and Azure App Service logs first, focusing on the deployed package and the /home/site/wwwroot/node_modules/.bin/keystone failure. Done means the Keystone Admin UI is accessible after deployment and startup no longer reports MODULE_NOT_FOUND for ../scripts.

Written by the indexing model from the issue text.

Description

I created a simple Keystone JS app which runs fine locally. I tried deploying it to Azure App Service using GIthub actions. My workflow file:
`
name: Build and deploy Node.js app to Azure Web App - keystonetestagain

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
  - uses: actions/checkout@v4

  - name: Set up Node.js version
    uses: actions/setup-node@v4
    with:
      node-version: '20.x'

  - name: npm install, build, and test
    run: |
      npm install
      npm run build --if-present
      # npm run test --if-present

  - name: Zip artifact for deployment
    run: zip release.zip ./* -r

  - name: Upload artifact for deployment job
    uses: actions/upload-artifact@v3
    with:
      name: node-app
      path: release.zip

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
  - name: Download artifact from build job
    uses: actions/download-artifact@v3
    with:
      name: node-app

  - name: Unzip artifact for deployment
    run: unzip release.zip
  
  - name: Login to Azure
    uses: azure/login@v1
    with:
      client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_C400F12F0E8B4117A7411E9521FE76FF }}
      tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_8FB1CA952DDC44BC9E1FF235ECB9641A }}
      subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_6E81A4870FF14BEF9340A1D315A06B25 }}

  - name: 'Deploy to Azure Web App'
    id: deploy-to-webapp
    uses: azure/webapps-deploy@v2
    with:
      app-name: 'keystonetestagain'
      slot-name: 'Production'
      publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
      package: .

`

Though the deployment ran successfully Keystone Admin UI is not accessible. When I check the Application logs I am seeing the following errors:
2024-03-27T11:08:41.519337232Z npm start 2024-03-27T11:08:54.435141246Z npm info using [email protected] 2024-03-27T11:08:54.436281663Z npm info using [email protected] 2024-03-27T11:08:54.797558523Z 2024-03-27T11:08:54.797591023Z > [email protected] start 2024-03-27T11:08:54.797597024Z > keystone start 2024-03-27T11:08:54.797600424Z 2024-03-27T11:08:58.679823860Z npm http fetch GET 200 https://registry.npmjs.org/npm 3975ms (cache updated) 2024-03-27T11:08:59.084723958Z npm http fetch GET 200 https://registry.npmjs.org/npm 4365ms (cache updated) 2024-03-27T11:09:00.654423991Z node:internal/modules/cjs/loader:1147 2024-03-27T11:09:00.654461192Z throw err; 2024-03-27T11:09:00.654466692Z ^ 2024-03-27T11:09:00.654470192Z 2024-03-27T11:09:00.654473292Z Error: Cannot find module '../scripts' 2024-03-27T11:09:00.654476692Z Require stack: 2024-03-27T11:09:00.654479892Z - /home/site/wwwroot/node_modules/.bin/keystone 2024-03-27T11:09:00.654483292Z at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15) 2024-03-27T11:09:00.654486892Z at Module._load (node:internal/modules/cjs/loader:985:27) 2024-03-27T11:09:00.654490392Z at Module.require (node:internal/modules/cjs/loader:1235:19) 2024-03-27T11:09:00.654493592Z at Module.patchedRequire [as require] (/agents/nodejs/node_modules/diagnostic-channel/dist/src/patchRequire.js:16:46) 2024-03-27T11:09:00.654496992Z at require (node:internal/modules/helpers:176:18) 2024-03-27T11:09:00.654500192Z at Object.<anonymous> (/home/site/wwwroot/node_modules/.bin/keystone:3:1) 2024-03-27T11:09:00.654592594Z at Module._compile (node:internal/modules/cjs/loader:1376:14) 2024-03-27T11:09:00.654596594Z at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) 2024-03-27T11:09:00.654599794Z at Module.load (node:internal/modules/cjs/loader:1207:32) 2024-03-27T11:09:00.654602994Z at Module._load (node:internal/modules/cjs/loader:1023:12) { 2024-03-27T11:09:00.654606194Z code: 'MODULE_NOT_FOUND', 2024-03-27T11:09:00.654609294Z requireStack: [ '/home/site/wwwroot/node_modules/.bin/keystone' ] 2024-03-27T11:09:00.654612694Z } 2024-03-27T11:09:00.661794111Z 2024-03-27T11:09:00.661839012Z Node.js v20.11.0

Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
38

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from keystonejs/keystone

All issues in keystonejs/keystone

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.