I'm pretty new to Docker and Azure as a whole so please bear with me..
FOR STARTERS
I have a Linux container based Docker Image which I am able to run and connect to successfully locally.
Here is the dockerfile I've put together
#Use microsoft's sdk image for build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /app
#1. copy csproj and restore as distinct layers
COPY *.sln .
COPY Client.Web/*.csproj ./Client.Web/
COPY DataOneDecoder/*.csproj ./DataOneDecoder/
COPY DealershipTenant/*.csproj ./DealershipTenant/
COPY Portal.Web/*.csproj ./Portal.Web/
COPY Multitenancy/*.csproj ./Multitenancy/
COPY Shared/*.csproj ./Shared/
COPY AdfSerialization/*.csproj ./AdfSerialization/
#2. dotnet-restore
RUN dotnet restore
#3. copy everything else and build app
COPY Client.Web/. ./Client.Web/
COPY DataOneDecoder/. ./DataOneDecoder/
COPY DealershipTenant/. ./DealershipTenant/
COPY Portal.Web/. ./Portal.Web/
COPY Multitenancy/. ./Multitenancy/
COPY Shared/. ./Shared/
COPY AdfSerialization/. ./AdfSerialization/
#4. Install nodejs and npm
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN echo "NODE Version: " && node --version
RUN echo "NPM Version: " && npm --version
#5. Navigate to Portal.Web and install npm dependencies
WORKDIR /app/Portal.Web
RUN npm install
#6. Build and publish solution
WORKDIR /app/
RUN dotnet publish -c Release -o out
#7. Copy built application to runtime image, expose port 5000, and define entrypoint
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS runtime
COPY --from=build /app/out ./
EXPOSE 5000
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "Portal.Web.dll"]
Locally, I am able to open the application on port 80 mapped to port 5000 (Exposed in the dockerfile) using the following commands
docker build -t exampleApp . --no-cache
docker run -d -p 80:5000 --name exampleContainer exampleApp
Now over in Azure land, I've set up a gitlab pipeline which builds and deploys the container to my Azure Container Registry.
From there I'm using the CLI to deploy the container to a Container Group and ultimately as a Container Instance
az container create \
--name dstestacg \
--resource-group $RES_GROUP \
--image $ACR_LOGIN_SERVER/portal_web_test:38b63ff933ea5a04b9ed7906ee01db33afb9abb6 \
--registry-login-server $ACR_LOGIN_SERVER \
--registry-username $(az keyvault secret show --vault-name $AKV_NAME -n $ACR_NAME-pull-usr --query value -o tsv) \
--registry-password $(az keyvault secret show --vault-name $AKV_NAME -n $ACR_NAME-pull-pwd --query value -o tsv) \
--restart-policy Never \
--ip-address Public \
--cpu 2 \
--memory 3.5 \
--ports 80 \
--environment-variables 'ASPNETCORE_URLS'='http://*:5000' \
--command-line "tail -f /dev/null"
It appears the application is running (I'm seeing resource usage spike, moreso than I experienced when the app wasn't running) but I cannot connect on the public ip with port 80. I end up with an "ERR_CONNECTION_RESET" error in the browser
I'm a little unclear on how this is being hosted on a non-windows machine. I believe it's with Kestrel, which I'm assuming my local Linux container of this was using. I'm unsure why I'm able access the container on port 80 locally but not as an Azure Container Instance.
Any assistance would be greatly appreciated, and if you need any more details please ask.
Thanks!
Updated Docker file and Azure CLI command after discussion about port mapping
#Use microsoft's sdk image for build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /app
#1. copy csproj and restore as distinct layers
COPY *.sln .
COPY Client.Web/*.csproj ./Client.Web/
COPY DataOneDecoder/*.csproj ./DataOneDecoder/
COPY DealershipTenant/*.csproj ./DealershipTenant/
COPY Portal.Web/*.csproj ./Portal.Web/
COPY Multitenancy/*.csproj ./Multitenancy/
COPY Shared/*.csproj ./Shared/
COPY AdfSerialization/*.csproj ./AdfSerialization/
#2. dotnet-restore
RUN dotnet restore
#3. copy everything else and build app
COPY Client.Web/. ./Client.Web/
COPY DataOneDecoder/. ./DataOneDecoder/
COPY DealershipTenant/. ./DealershipTenant/
COPY Portal.Web/. ./Portal.Web/
COPY Multitenancy/. ./Multitenancy/
COPY Shared/. ./Shared/
COPY AdfSerialization/. ./AdfSerialization/
#4. Install nodejs and npm
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN echo "NODE Version: " && node --version
RUN echo "NPM Version: " && npm --version
#5. Navigate to Portal.Web and install npm dependencies
WORKDIR /app/Portal.Web
RUN npm install
#6. Build and publish solution
WORKDIR /app/
RUN dotnet publish -c Release -o out
#7. Copy built application to runtime image, expose port 5000, and define entrypoint
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS runtime
COPY --from=build /app/out ./
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS=http://*:5000
ENV ASPNETCORE_ENVIRONMENT=Development
ENTRYPOINT ["dotnet", "Portal.Web.dll"]
az container create \
--name idkman \
--resource-group $RES_GROUP \
--image $ACR_LOGIN_SERVER/portal_web_test:deb5e784f1a7f9904f50a97b93ff42380b85158c \
--registry-login-server $ACR_LOGIN_SERVER \
--registry-username $(az keyvault secret show --vault-name $AKV_NAME -n $ACR_NAME-pull-usr --query value -o tsv) \
--registry-password $(az keyvault secret show --vault-name $AKV_NAME -n $ACR_NAME-pull-pwd --query value -o tsv) \
--restart-policy Never \
--ip-address Public \
--cpu 2 \
--memory 3.5 \
--ports 5000 \
--environment-variables 'PORT'='5000'