microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
372 stars 29 forks source link

Next.js deploy: The TargetPort 3000 does not match the listening port 80. #1260

Open dfberry opened 3 months ago

dfberry commented 3 months ago

Please provide us with the following information:

This issue is a: (mark with an x)

Issue description

The container exposes port 3000 and the app runs on port 3000. I'm not sure what else to try.

Steps to reproduce

  1. Test image: can use host browser to connect to port 3000 in container to access site.
  2. Push image to my registry.
  3. Create resource and open ingress with Azure CLI:
az containerapp create \
--subscription $AZURE_SUBSCRIPTION_ID \
--resource-group $AZURE_RESOURCE_GROUP \
--name $AZURE_CONTAINER_APP_NAME \
--environment ${AZURE_CONTAINER_APP_ENV_NAME}

# Enable ingress for Azure Container App
az containerapp ingress enable \
--subscription $AZURE_SUBSCRIPTION_ID \
--name $AZURE_CONTAINER_APP_NAME \
--resource-group $AZURE_RESOURCE_GROUP \
--target-port $TARGET_PORT \
--transport http \
--type external 
  1. Deploy image from GitHub actions.
  2. Image is deployed but revision fails.
image

Expected behavior [What you expected to happen.]

I'm not sure why it thinks my container only has the default port open. Could there be an underlying issue with the revision creation?

Actual behavior [What actually happened.]

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

I'm not having this issue with any other apps, just Next.js. I did see that @manekinekko set the environment variable for the port in his app so I tried that but that didn't seem to help.

I'm going to try to pull down the image from the registry locally and make sure I can still use it in case somehow the image is messed up.

@craigshoemaker @anthonychu

anthonychu commented 3 months ago

Investigated with @dfberry and found that the app was being updated to a non-existent image. The app was therefore still running the quickstart image, which runs on port 80. We'll investigate why the deployment appeared successful even though the image doesn't exist.

mjad218 commented 2 months ago

I am getting the same error, when deploying a Next.js app to Container Apps.

diberry commented 2 months ago

@mjad218 can you verify that the container app is running your container and not the hello world container? On the resource, if you look at the JSON, it will tell you which image was deployed.

My issue was that my image wasn't referenced correctly in the deployment so the helloworld was deployed which uses a different port.

mjad218 commented 2 months ago

It's running the hello world. I created another Container App with the image I want and it's working now.

Thanks mate