# Basimage för runtime
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

# Installera svenska språkinställningar
RUN apt-get update && \
    apt-get install -y locales && \
    locale-gen sv_SE.UTF-8

# Ställ in svenska som standard
ENV LANG=sv_SE.UTF-8
ENV LANGUAGE=sv_SE:sv
ENV LC_ALL=sv_SE.UTF-8
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

WORKDIR /app
EXPOSE 80
EXPOSE 443

VOLUME /app/data

# Byggimage med SDK
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src

# Kopiera endast .csproj först för att kunna cacha restore
COPY ["Aberwyn/Aberwyn.csproj", "Aberwyn/"]
WORKDIR /src/Aberwyn

# Restore beroenden
RUN dotnet restore "Aberwyn.csproj"

# Kopiera övrig kod
COPY Aberwyn/. .

# Bygg utan att köra restore igen
RUN dotnet build "Aberwyn.csproj" -c Release -o /app/build --no-restore

# Publicera utan att köra restore eller build igen
FROM build AS publish
RUN dotnet publish "Aberwyn.csproj" -c Release -o /app/publish --no-restore

# Slutgiltig image baserad på runtime
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "Aberwyn.dll"]
