-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (55 loc) · 2.1 KB
/
Copy pathDockerfile
File metadata and controls
72 lines (55 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# syntax=docker/dockerfile:1.4
# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy solution and project files first to leverage layer caching
COPY Source/Reef.slnx ./
COPY Source/Directory.Packages.props ./
COPY Source/Reef.Tests/*.csproj ./Reef.Tests/
COPY Source/Reef/*.csproj ./Reef/
# Restore dependencies (use BuildKit cache for NuGet packages)
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet restore ./Reef.slnx
# Copy the remaining source files
COPY Source/ .
# Publish the Reef project
WORKDIR /src/Reef
# Clone .git into Reef directory for MinVer
# (MinVer requires .git to determine version from tags)
RUN git init && \
git remote add origin $(git -C /src remote get-url origin 2>/dev/null || echo "https://github.com/melosso/reef.git") && \
git fetch --tags origin main && \
git reset --soft FETCH_HEAD
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish Reef.csproj -c Release -o /app/publish /p:UseAppHost=false
# Copy views folder explicitly (check if it exists first)
RUN ls -la /src/Reef/ && \
if [ -d /src/Reef/Views ]; then \
cp -r /src/Reef/Views /app/publish/views; \
echo "Views folder copied successfully"; \
else \
echo "Warning: Views folder not found at /src/Reef/Views"; \
fi
# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
# Install sqlite3 and curl for runtime healthchecks and basic tools
RUN apt-get update && apt-get install -y --no-install-recommends \
sqlite3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create directories used by the application
RUN mkdir -p /app/exports /app/log /app/.core /app/data
# Set environment variables
ENV ASPNETCORE_HTTP_PORTS=8085
ENV ASPNETCORE_ENVIRONMENT=Production
ENV REEF_ENCRYPTION_KEY=""
# Copy published output
COPY --from=build /app/publish .
# Ensure permissions
RUN chmod -R 755 /app
# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8085/health || exit 1
EXPOSE 8085
ENTRYPOINT ["dotnet", "Reef.dll"]