Dockerfile for Umbraco 13
s
Does anyone have a good working example of a Dockerfile for Umbraco 13. I'm having all kinds of issues with permissions and the site not booting. Anything I've searched has been older versions. Also, I'm targeting Linux.
c
Copy code
USER root
RUN chmod o=rw /app/wwwroot/
RUN chmod o=rw /app/Views/
had to change the permissions on those two directories
This got us running in linux containers (running in Azure Container Apps)
a
My dockerfile is nothing else then the basic VisualStudio generated one
Copy code
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["ProjectName/ProjectName.csproj", "ProjectName/"]
COPY ["ProjectName.Business/ProjectName.Business.csproj", "ProjectName.Business/"]
COPY ["ProjectName.Data/ProjectName.Data.csproj", "ProjectName.Data/"]
RUN dotnet restore "ProjectName/ProjectName.csproj"
COPY . .
WORKDIR "/src/ProjectName"
RUN dotnet build "ProjectName.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ProjectName.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ProjectName.dll"]
c
@Ambert That's not on .NET8 though.. which changed the permission model for containers to no longer run as root
a
Hmm, I havent tested that yet, correct
curious if ill encounter the same issue
Have just made the upgrade locally to v13, so could check it today/tomorrow if it runs on my azure container
l
https://github.com/liamlaverty/ideal-umbrella/blob/main/IU.Docker/dockerfile.umbracosite https://github.com/liamlaverty/ideal-umbrella/blob/main/docker-compose.yml This repo has a working dockerfile for Umbraco13. The
docker-compose.yml
file launches both a backoffice & front-end Umb site from that
dockerfile.umbracosite
a
Yea same issue here, site wont come up
Copy code
unhandled exception. System.UnauthorizedAccessException: Access to the path '/app/umbraco/Data' is denied.
Definitly permission issue, uf
i
you might need to delete the umbraco folder if its in a named volume. If it creates it itself the problem is solved
You do need this though @Ambert
a
Will check in a min, thanks, missed your message
Copy code
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 8080
EXPOSE 8081
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /src
COPY ["ProjectName/ProjectName.csproj", "ProjectName/"]
COPY ["ProjectName.Business/ProjectName.Business.csproj", "ProjectName.Business/"]
COPY ["ProjectName.Data/ProjectName.Data.csproj", "ProjectName.Data/"]
RUN dotnet restore "ProjectName/ProjectName.csproj"
COPY . .
WORKDIR "/src/ProjectName"
RUN dotnet build "ProjectName.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ProjectName.csproj" -c Release -o /app/publish
RUN chmod o=rw /app/publish/wwwroot/
RUN chmod o=rw /app/publish/Views/

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ProjectName.dll"]
What worked for me is adding the chmods (Didnt need to add the user root), and also the Expose ports as in .net 8 the port is default 8080. In my Appservice I added an environment variabele called WEBSITES_PORT with 8080 and all is working for now, not sure if this is the best approach though 🙂
s
Ahhh! So I was trying to set permissions in the final stage and it was giving me a hard time. Thanks everyone! Really appreciate the help!
408 Views