English 中文(简体)
Deploying a next.js apptor to Web App: files not
原标题:Deploying a next.js app to Azure Web App: Files not found

I m trying to deploy a next.js (with typescript) app on Azure, using Bitbucket pipelines. In my pipeline, I build the next.js, with build config the following:

// next.config.js

/**@type {import( next ).NextConfig} */
const nextConfig = {
   output:  standalone ,
}
module.exports = nextConfig

之后,我部署了它。

    - step: &deploy-preview
        caches:
          - node
          - nextcache
        script:
          - zip -r files.zip .next/ public/
          - pipe: microsoft/azure-web-apps-deploy:1.0.4
            variables:
              AZURE_APP_ID: $AZURE_APP_ID
              AZURE_PASSWORD: $AZURE_PASSWORD
              AZURE_TENANT_ID: $AZURE_TENANT_ID
              AZURE_RESOURCE_GROUP: $AZURE_RESOURCE_GROUP
              AZURE_APP_NAME: $AZURE_APP_NAME
              ZIP_FILE:  files.zip 
        artifacts:
          - "files.zip"

If I take a look at the artifacts folder it does contain all the files I expect. On the Azure web App i have the startup command node .next/standalone/server.js

该系统的确启用了一台下台服务器,但无法找到文件。 我的奥塞莱认为,他们都是404人。 然而,档案是存在的。

谁能让我对正在做些什么以及可能做些什么来加以纠正?

最佳回答

对于同一问题的人来说。 我在通过下一代的docs挖后解决了这个问题。

https://nextjs.org/docs/pages/api-fer/next-config-js/output#autally-copying-traced-files

它指出,就单独会议而言:

这一最低限度的服务器does not拷贝 the public or .next/static rafters byail as these should diely be addressed by a CDN,, 不过,这些夹可与独立/公开和独立/.next/static rafters Manually

If you develop locally, your local machine will act as this CDN. But on Azure, the web app does not act as a CDN, so it s important to copy these files over. This can be done in the bitbucket script.

a. 彩票实例:

image: node:18

definitions:
  steps:
    - step: &deploy-production
        name:  Deploy 
        deployment: Production
        script:
          - apt-get update
          - apt-get install zip
          - "mkdir .next/standalone/.next/static"
          - "cp -r .next/static/* .next/standalone/.next/static"
          - "mkdir .next/standalone/public"
          - "cp -r public/* .next/standalone/public"
          - zip -r standalone.zip .next/* 
          - pipe: microsoft/azure-web-apps-deploy:1.0.4
            variables:
              AZURE_APP_ID: $AZURE_APP_ID
              AZURE_PASSWORD: $AZURE_PASSWORD
              AZURE_TENANT_ID: $AZURE_TENANT_ID
              AZURE_RESOURCE_GROUP:  frontend 
              AZURE_APP_NAME: $AZURE_APP_NAME
              ZIP_FILE:  standalone.zip 
        artifacts:
          - "standalone.zip"
pipelines:
  # Build, test and deploy on master branch.
  branches:
    master:
      - step: *deploy-production

其他会议:

  1. I chose Node 18 LTS on Linux servers as the chosen runtime environment.
  2. The startup command under Settings > Configuration > General Settings is node ./next/standalone/server.js.
  3. If .env variables are introduced, configure them on Azure under Configuration > Application Settings.
问题回答

暂无回答




相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...