I built a react app and I created a docker file that uses the nginx image. I can build and run the docker container locally and it serves up my react app sucessfully. However when I try and deploy this to azure app service it is failing for some reason. In the logs in logstream it just says "Your container failed to start up" What confuses me is that I am deploying this in a very similar way to how I have successfully deployed hundreds of java containers running springboot apps. In this situation I have no problem, but for some reason it is taking me days to get this nginx/react app working on app service.
I am provisioning the app service with terraform. The code looks like this.
resource "azurerm_app_service_plan" "dpt_appservice_plan" {
name = "${var.ENVIRONMENT}-dpt-app-service-plan"
location = azurerm_resource_group.dpt_rg.location
resource_group_name = azurerm_resource_group.dpt_rg.name
kind = "Linux"
reserved = true
sku {
tier = "Basic"
size = "S1"
}
}
resource "azurerm_app_service" "dpt_my_website_app_service" {
name = "${var.ENVIRONMENT}-dpt-my-website-app-service"
location = azurerm_resource_group.dpt_rg.location
resource_group_name = azurerm_resource_group.dpt_rg.name
app_service_plan_id = azurerm_app_service_plan.dpt_appservice_plan.id
site_config {
always_on = false
linux_fx_version = "DOCKER|${var.ENVIRONMENT}<acr>.azurecr.io/<registry>:latest"
}
app_settings = {
DOCKER_REGISTRY_SERVER_URL = "https:# acr.azurecr.io"
DOCKER_REGISTRY_SERVER_USERNAME = azurerm_container_registry.dpt_acr.admin_username
DOCKER_REGISTRY_SERVER_PASSWORD = azurerm_container_registry.dpt_acr.admin_password
WEBSITES_PORT = 8080
WEBSITES_CONTAINER_START_TIME_LIMIT = 300
}
}
I build the react app and take the contents from the build directory and place them in the nginx container
FROM nginx
COPY build /usr/share/nginx/html
COPY docker/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 8080 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]
Does anybody know the correct way to deploy an nginx container with a react app to azure app service?