-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (72 loc) · 2.44 KB
/
Dockerfile
File metadata and controls
84 lines (72 loc) · 2.44 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
76
77
78
79
80
81
82
83
84
# =========================
# Backend Build Stage
# =========================
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS backend-build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY Backend/Backend.csproj ./Backend/
RUN dotnet restore "./Backend/Backend.csproj"
COPY Backend/ ./Backend/
WORKDIR "/src/Backend"
RUN dotnet publish "./Backend.csproj" -c $BUILD_CONFIGURATION -o /app/backend /p:UseAppHost=false
# =========================
# Frontend Build Stage
# =========================
FROM node:22-alpine AS frontend-build
WORKDIR /app
COPY FrontEnd/package*.json ./
RUN npm ci
COPY FrontEnd/ ./
RUN npm run build:ssr
# =========================
# Runtime Stage
# =========================
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
# Install Node.js and supervisor
RUN apt-get update && apt-get install -y \
curl \
supervisor \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy backend
COPY --from=backend-build /app/backend ./backend
# Copy frontend
COPY --from=frontend-build /app/dist ./frontend/dist
COPY --from=frontend-build /app/package*.json ./frontend/
WORKDIR /app/frontend
RUN npm ci --omit=dev
# Copy i18n assets
COPY --from=frontend-build /app/dist/what-grows-native-here/browser/assets/i18n ./dist/what-grows-native-here/browser/assets/i18n
COPY --from=frontend-build /app/dist/what-grows-native-here/browser/assets/i18n ./dist/what-grows-native-here/server/assets/i18n
# Configure supervisord
WORKDIR /app
COPY <<EOF /etc/supervisor/conf.d/supervisord.conf
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
[program:backend]
command=dotnet /app/backend/Backend.dll
directory=/app/backend
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/backend.err.log
stdout_logfile=/var/log/supervisor/backend.out.log
environment=ASPNETCORE_ENVIRONMENT="Production",ASPNETCORE_URLS="http://+:8080"
[program:frontend]
command=node dist/what-grows-native-here/server/server.mjs
directory=/app/frontend
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/frontend.err.log
stdout_logfile=/var/log/supervisor/frontend.out.log
environment=NODE_ENV="production",PORT="4000",API_URL="http://localhost:8080"
EOF
# Expose ports
EXPOSE 8080 4000
# Start supervisor
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]