英文:
Unable to deploy a Remix App to Azure App service using Azure Pipelines
问题
我使用 Remix App Server 模板构建了一个 Remix 应用程序。我正在尝试使用 Azure App Service 构建它。问题在于 "build" 命令生成了一个 .cache 文件夹,而在复制它时出现了权限问题。目标是在部署后运行 "npm run start"。
这是我的 YAML 文件:
# Node.js Express Web App to Linux on Azure
# Build a Node.js Express app and deploy it to Azure as a Linux web app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- development
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: <subscription_id>
# Web app name
webAppName: 'remix'
# Environment name
environmentName: 'remix-app'
# Agent VM image name
vmImageName: 'ubuntu-latest'
# PNPM Cache Location
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- task: Cache@2
inputs:
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml'
path: $(pnpm_config_cache)
displayName: Cache pnpm
- script: |
corepack enable
corepack prepare pnpm@latest-8 --activate
pnpm config set store-dir $(pnpm_config_cache)
displayName: 'Setup pnpm'
- script: |
pnpm install
pnpm run build
displayName: 'pnpm install, build'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: $(environmentName)
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: 'Azure Web App Deploy: remix'
inputs:
azureSubscription: $(azureSubscription)
appType: webAppLinux
appName: $(webAppName)
runtimeStack: 'NODE|18'
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
startUpCommand: 'npm run start'
这是我收到的错误信息。
英文:
I have a remix app built using the Remix App Server template. I am trying to build it using Azure App Service. The issue is that "build" command generates a .cache folder and there are issues with permissioning only while copying that. The goal is to run "npm run start" after the build is deployed.
This is my yml.
# Node.js Express Web App to Linux on Azure
# Build a Node.js Express app and deploy it to Azure as a Linux web app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- development
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: <subscription_id>
# Web app name
webAppName: 'remix'
# Environment name
environmentName: 'remix-app'
# Agent VM image name
vmImageName: 'ubuntu-latest'
# PNPM Cache Location
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- task: Cache@2
inputs:
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml'
path: $(pnpm_config_cache)
displayName: Cache pnpm
- script: |
corepack enable
corepack prepare pnpm@latest-8 --activate
pnpm config set store-dir $(pnpm_config_cache)
displayName: "Setup pnpm"
- script: |
pnpm install
pnpm run build
displayName: 'pnpm install, build'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: $(environmentName)
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: 'Azure Web App Deploy: remix'
inputs:
azureSubscription: $(azureSubscription)
appType: webAppLinux
appName: $(webAppName)
runtimeStack: 'NODE|18'
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
startUpCommand: 'npm run start'
This is the error I get.
答案1
得分: 1
我克隆了这个存储库,我使用了 Node.js React 应用程序,并将 Azure Web 应用程序作为 remix 与 react 更好地配合使用。
选择您的 Web 应用程序并运行 yaml 管道:
trigger:
- main
variables:
azureSubscription: 'azuresubscription-id'
# Web 应用程序名称
webAppName: 'siliconwebapp1'
# 环境名称
environmentName: 'siliconwebapp1'
# 代理 VM 映像名称
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: 构建阶段
jobs:
- job: Build
displayName: 构建
pool:
vmImage: $(vmImageName)
steps:
- task: ArchiveFiles@2
displayName: '归档文件'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: 部署阶段
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: 部署
environment: $(environmentName)
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service 部署: siliconwebapp1'
inputs:
azureSubscription: $(azureSubscription)
appType: webAppLinux
WebAppName: $(webAppName)
packageForLinux: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
RuntimeStack: 'NODE|10.10'
StartupCommand: 'npm run start'
ScriptType: 'Inline Script'
InlineScript: |
npm install
npm run build --if-present
上述方法不包括任何缓存任务或复制文件。但在您的任务中,您可以添加:
- script: |
pnpm install
npm run build
rm -rf .cache
displayName: 'pnpm 安装,构建和删除 .cache 文件夹'
在执行归档任务之前删除缓存文件。
如果您遇到与依赖关系相关的任何问题,请确保通过 npm 命令更新这些包。首先使用 npm run setup
和 npm run dev
命令在本地运行代码。如果应用程序在本地运行,请将代码推送到您的 Azure DevOps 管道并再次运行。
英文:
I cloned this repository I used Node.js React app with Azure Web app as remix works better with react.
Select your Web app and run the yaml pipeline:-
trigger:
- main
variables:
azureSubscription: 'azuresubscription-id'
# Web app name
webAppName: 'siliconwebapp1'
# Environment name
environmentName: 'siliconwebapp1'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: $(environmentName)
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Azure App Service Deploy: siliconwebapp1'
inputs:
azureSubscription: $(azureSubscription)
appType: webAppLinux
WebAppName: $(webAppName)
packageForLinux: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
RuntimeStack: 'NODE|10.10'
StartupCommand: 'npm run start'
ScriptType: 'Inline Script'
InlineScript: |
npm install
npm run build --if-present
Above method does not include any cache task or copy files. But in your task you can add:-
- script: |
pnpm install
npm run build
rm -rf .cache
displayName: 'pnpm install, build, and delete .cache folder'
To remove the cache files before archive task.
If you face any issues related to the dependencies make sure you update those packages via npm commands. First run the code locally with npm run setup
and npm run dev
command. If the app runs locally, Push the code in your Azure DevOps pipeline and run again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论