mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-31 13:12:27 +00:00
* Add lighthouse docker support * Update to NET 7.0 * Make docker copy git repository info * Add restart policy to compose file * Delete temp folder after copying to data * Only build the docker image once * Fix builds from being dirty * Add su-exec to final image * Run lighthouse as non root user * Add compose file to gitignore * Remove compose file from gitignore Co-authored-by: Dagg <daggintosh@outlook.com>
40 lines
1.2 KiB
Docker
40 lines
1.2 KiB
Docker
# Build stage
|
|
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
|
WORKDIR /ProjectLighthouse
|
|
COPY *.sln ./
|
|
COPY **/*.csproj ./
|
|
|
|
RUN dotnet sln list | grep ".csproj" \
|
|
| while read -r line; do \
|
|
mkdir -p $(dirname $line); \
|
|
mv $(basename $line) $(dirname $line); \
|
|
done;
|
|
|
|
RUN dotnet restore
|
|
|
|
COPY . .
|
|
RUN dotnet publish -c Release -o /ProjectLighthouse/publish --no-restore
|
|
|
|
# Final running container
|
|
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine AS final
|
|
|
|
# Add non-root user
|
|
RUN addgroup -S lighthouse --gid 1001 && \
|
|
adduser -S lighthouse -G lighthouse -h /lighthouse --uid 1001 && \
|
|
mkdir -p /lighthouse/data && \
|
|
mkdir -p /lighthouse/app && \
|
|
mkdir -p /lighthouse/temp && \
|
|
apk add --no-cache icu-libs su-exec
|
|
|
|
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
|
|
|
# Copy build files
|
|
COPY --from=build /ProjectLighthouse/publish /lighthouse/app
|
|
COPY --from=build /ProjectLighthouse/ProjectLighthouse/StaticFiles /lighthouse/temp/StaticFiles
|
|
COPY --from=build /ProjectLighthouse/scripts-and-tools/docker-entrypoint.sh /lighthouse
|
|
|
|
RUN chown -R lighthouse:lighthouse /lighthouse && \
|
|
chmod +x /lighthouse/docker-entrypoint.sh && \
|
|
cp /lighthouse/app/appsettings.json /lighthouse/temp
|
|
|
|
ENTRYPOINT ["/lighthouse/docker-entrypoint.sh"]
|