Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to deploy Keystone JS app to Azure app service #9070

Open
sambaran69 opened this issue Mar 28, 2024 · 1 comment
Open

Unable to deploy Keystone JS app to Azure app service #9070

sambaran69 opened this issue Mar 28, 2024 · 1 comment

Comments

@sambaran69
Copy link

sambaran69 commented Mar 28, 2024

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 npm@9.6.4 2024-03-27T11:08:54.436281663Z npm info using node@v20.11.0 2024-03-27T11:08:54.797558523Z 2024-03-27T11:08:54.797591023Z > keystone-app@1.0.2 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

@iamandrewluca
Copy link
Contributor

iamandrewluca commented Apr 17, 2024

"Zip artifact for deployment" does not include all the files.

e.g.

ls -la
total 0
drwxr-xr-x   5 iamandrewluca  staff   160 Apr 18 00:09 .
drwxr-xr-x  73 iamandrewluca  staff  2336 Apr 18 00:09 ..
-rw-r--r--   1 iamandrewluca  staff     0 Apr 18 00:09 .file2
drwxr-xr-x   3 iamandrewluca  staff    96 Apr 18 00:10 .folder
-rw-r--r--   1 iamandrewluca  staff     0 Apr 18 00:09 file1

This does not include all the files

zip -r file.zip ./*
  adding: file1 (stored 0%)

This includes all the files

zip -r file2.zip ./
  adding: .folder/ (stored 0%)
  adding: .folder/test (stored 0%)
  adding: file1 (stored 0%)
  adding: .file2 (stored 0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants