Skip to content

Commit ced1c15

Browse files
committed
Including appsettings in the docker image
1 parent c4e26af commit ced1c15

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

Dockerfile.production

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,33 @@ RUN dotnet build "PWABuilder.csproj" -c Release -o /app/build
7171
FROM build AS publish
7272
RUN dotnet publish "PWABuilder.csproj" -c Release -o /app/publish /p:UseAppHost=false
7373

74-
# Final stage
75-
FROM base AS final
74+
# Final stage/image
75+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
76+
77+
# Install Chrome dependencies and create non-root user
78+
RUN apt-get update \
79+
&& apt-get install -y wget gnupg \
80+
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
81+
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
82+
&& apt-get update \
83+
&& wget -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_130.0.6723.116-1_amd64.deb \
84+
&& apt-get install -y /tmp/chrome.deb \
85+
&& rm /tmp/chrome.deb \
86+
&& apt-get purge -y --auto-remove wget gnupg \
87+
&& rm -rf /var/lib/apt/lists/* \
88+
&& groupadd -r pwabuilder && useradd -r -g pwabuilder -d /app -s /bin/bash pwabuilder \
89+
&& chown -R pwabuilder:pwabuilder /app
90+
7691
WORKDIR /app
92+
EXPOSE 8080
93+
94+
# Copy from publish stage
7795
COPY --from=publish /app/publish .
7896

97+
# Explicitly copy environment-specific appsettings files
98+
COPY --from=build /src/appsettings.Production.json ./appsettings.Production.json
99+
COPY --from=build /src/appsettings.Staging.json ./appsettings.Staging.json
100+
79101
# Enable detailed logging for debugging
80102
ENV ASPNETCORE_DETAILEDERRORS=true
81103
ENV Logging__LogLevel__Default=Information

apps/pwabuilder/PWABuilder.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,14 @@
5050
<ItemGroup>
5151
<None Include="Resources\IOS\**" CopyToOutputDirectory="PreserveNewest" />
5252
</ItemGroup>
53+
54+
<!-- Explicitly include environment-specific appsettings files in publish -->
55+
<ItemGroup>
56+
<Content Include="appsettings.Production.json">
57+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
58+
</Content>
59+
<Content Include="appsettings.Staging.json">
60+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
61+
</Content>
62+
</ItemGroup>
5363
</Project>

0 commit comments

Comments
 (0)