Closed jgador closed 2 years ago
Are you sure the container is running? The problem could be in the docker build
@Laranjeiras Yes, I can confirm that the container is running from the Azure App Service -> Monitoring -> Log stream.
Hi @jgador. We were unable to reproduce the problem. This behavior is possible if the connection string is not written to the App_Data/dataSettings.json file. Maybe the process may not have access to this file.
Thanks for looking into this @skoshelev. I am still unable to resolve this when deploying to Azure App Service as container. This ticket may be close if others has no issues related to mine while I continue my investigation.
Hi @jgador. We will be happy to help you if you find more information about the problem. But first of all, make sure that the correct security settings are set for the dataSettings.json file in the container. you can also enable logging to the file system in the web.config file. Perhaps some kind of failure occurs during installation.
Hi guys, I'm having the same difficulty to implement the serveless nop... and I'm already using:
RUN mkdir App_Data WORKDIR /app/App_Data RUN echo "" > dataSettings.json RUN echo "" > appSettings.json WORKDIR /app
in dockerfile.. :(
We were unable to reproduce the problem
Closed #5849
For anyone still having this problem, I am running on Azure App Service (Linux) with no problem. Although I didn't have this exact problem I ran into a few issues and would recommend building your own docker image. You can do this with a slightly modified version of the dockerfile from this repo:
# create the build instance
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ./src ./
COPY packages/. packages/.
# build project
WORKDIR /src/Presentation/Nop.Web
RUN dotnet restore Nop.Web.csproj -s /src/packages -s https://api.nuget.org/v3/index.json
RUN dotnet build Nop.Web.csproj -c Release
# build plugins - some removed for brevity
WORKDIR /src/Plugins/Nop.Plugin.Shipping.FixedByWeightByTotal
RUN dotnet restore Nop.Plugin.Shipping.FixedByWeightByTotal.csproj -s /src/packages -s https://api.nuget.org/v3/index.json
RUN dotnet build Nop.Plugin.Shipping.FixedByWeightByTotal.csproj -c Release
WORKDIR /src/Plugins/Nop.Plugin.Tax.FixedOrByCountryStateZip
RUN dotnet restore Nop.Plugin.Tax.FixedOrByCountryStateZip.csproj -s /src/packages -s https://api.nuget.org/v3/index.json
RUN dotnet build Nop.Plugin.Tax.FixedOrByCountryStateZip.csproj -c Release
# publish project
WORKDIR /src/Presentation/Nop.Web
RUN dotnet publish Nop.Web.csproj -c Release -o /app/published
# remove anything that is handled within Azure File Storage
RUN rm -r /app/published/App_Data
RUN rm -r /app/published/wwwroot/images
# create the runtime instance
FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS runtime
# add globalization support
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
# installs required packages
RUN apk add libgdiplus --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
RUN apk add libc-dev --no-cache
# Enable and configure SSH
# if you don't do this then SSH doesn't work from within the Azure portal
# and also you can't connect to SSH via the Azure proxy
RUN apk add --no-cache --update openssh-server \
&& echo "root:Docker!" | chpasswd
COPY sshd_config /etc/ssh/
# Endpoint script
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod 0755 /entrypoint.sh
WORKDIR /app
EXPOSE 80 2222
RUN mkdir bin
RUN mkdir logs
COPY --from=build /app/published .
ENTRYPOINT "/entrypoint.sh"
The entrypoint.sh script should contain the following in order to setup SSH and should be saved with 'Unicode - Codepage 1200' encoding otherwise it will not run correctly:
#!/bin/bash
ssh-keygen -A
/usr/sbin/sshd
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
exec dotnet Nop.Web.dll
Then under the App Service configuration page setup path mappings for App_Data and images:
Ensure you copy the required files to these shares before starting the app.
I would recommend that you setup NopCommerce to use Azure Blob storage for it's images, but you will still need the images file share in order to persist uploaded images between app restarts. This contains the 'original' images that get resized when necessary and then stored on the blob storage.
Note: You will notice that the dockerfile sets the SSH password for root to 'Docker!'. It is important that it isn't changed as this is what the Azure portal expects to login with. It is secure as the SSH endpoint is never exposed to the outside world. In order to connect it has to be done either via the portal or an authenticated SSH proxy via PowerShell.
Hopefully this helps someone. There are many ways to get NopCommerce running on App Service but this is based on our experience and was put into place to resolve a lot of issues we had.
One thing that this doesn't address is caching across multiple nodes which, at time of writing, we haven't found works correctly. We had this implemented using Redis but the currently open issue #5593 has meant that we've had to switch back to a single node implementation for the time being.
@purplepiranha Thank you for spending time and providing solution. I am now able to run nopCommerce in Azure App Service. So, my problem is that, I did not have a mounted Azure File for App_Data. When the application restarts, the appsettings and datasettings were gone. But with your explanation, I gain additional knowledge especially on the SSH also.
nopCommerce version: 4.40.4
Steps to reproduce the problem: Deploy nopCommerce docker from dockerhub to Azure App Service (Linux) Proceed with installation After installation, I am stuck at the
/install
page and could not proceed. Restart the Azure App Service Still stuck at the/install
pageI checked with the database to see if the migration works, and it did.