-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (52 loc) · 1.76 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (52 loc) · 1.76 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
73
74
75
# Multi-stage Dockerfile for F# Counter App
# Stage 1: Build frontend
FROM node:22-alpine AS frontend-build
WORKDIR /app
# Install .NET SDK for Fable compilation (needed before npm install for vite-plugin-fable)
RUN apk add --no-cache dotnet9-sdk
# Copy package files
COPY package.json package-lock.json* ./
# Copy F# project files (needed for npm install - vite-plugin-fable postinstall)
COPY src/Client/Client.fsproj ./src/Client/
COPY src/Shared/Shared.fsproj ./src/Shared/
# Install npm dependencies
RUN npm install
# Copy source files
COPY src/Client ./src/Client
COPY src/Shared ./src/Shared
COPY vite.config.js tailwind.config.js ./
# Restore .NET dependencies
RUN dotnet restore src/Client/Client.fsproj
# Build frontend
RUN npm run build
# Stage 2: Build backend
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS backend-build
WORKDIR /app
# Copy project files
COPY src/Shared/Shared.fsproj ./src/Shared/
COPY src/Server/Server.fsproj ./src/Server/
# Restore dependencies
RUN dotnet restore src/Server/Server.fsproj
# Copy source code
COPY src/Shared ./src/Shared
COPY src/Server ./src/Server
# Build backend
RUN dotnet publish src/Server/Server.fsproj -c Release -o /app/publish
# Stage 3: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS runtime
WORKDIR /app
# Install curl for healthchecks
RUN apk add --no-cache curl
# Copy backend from build stage
COPY --from=backend-build /app/publish .
# Copy frontend from build stage
COPY --from=frontend-build /app/dist/public ./dist/public
# Create data directory for persistence
RUN mkdir -p /app/data
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5000/ || exit 1
# Run the application
ENTRYPOINT ["dotnet", "Server.dll"]