Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (51 loc) · 2.81 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (51 loc) · 2.81 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
# === Stage 1: Build ===
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
WORKDIR /src
# Copy solution and project files for layer-cached restore
COPY ["src/InventoryManagementSystem.sln", "./"]
COPY ["src/Directory.Packages.props", "./"]
COPY ["src/InventoryAlert.Domain/InventoryAlert.Domain.csproj", "InventoryAlert.Domain/"]
COPY ["src/InventoryAlert.Infrastructure/InventoryAlert.Infrastructure.csproj", "InventoryAlert.Infrastructure/"]
COPY ["src/InventoryAlert.Api/InventoryAlert.Api.csproj", "InventoryAlert.Api/"]
COPY ["src/InventoryAlert.Worker/InventoryAlert.Worker.csproj", "InventoryAlert.Worker/"]
# Restore dependencies
RUN dotnet restore "InventoryAlert.Api/InventoryAlert.Api.csproj"
RUN dotnet restore "InventoryAlert.Worker/InventoryAlert.Worker.csproj"
# Copy full source and publish API and Worker
COPY src/ .
RUN dotnet publish "InventoryAlert.Api/InventoryAlert.Api.csproj" \
-c Release \
--no-restore \
-o /app/publish/api
RUN dotnet publish "InventoryAlert.Worker/InventoryAlert.Worker.csproj" \
-c Release \
--no-restore \
-o /app/publish/worker
# === Stage 2: Runtime ===
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS final
WORKDIR /app
# Install security, diagnostic, AWS CLI, and Python Moto server dependencies for Render deployment
RUN apk add --no-cache icu-libs curl gcompat libgdiplus krb5-libs python3 py3-pip && \
pip install --no-cache-dir --break-system-packages "moto[server]" awscli
# Configure runtime for Alpine (Globalization & File Watcher)
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV DOTNET_USE_POLLING_FILE_WATCHER=true
ENV ASPNETCORE_URLS=http://+:8080
COPY --from=build /app/publish/api ./api
COPY --from=build /app/publish/worker ./worker
COPY src/SolutionFolder/moto-init/init-all.sh ./init-all.sh
# Startup script: Starts Moto server, runs Moto initialization (SQS/SNS/DynamoDB tables), starts Worker on internal port 8081, and runs API on public port 8080
RUN echo '#!/bin/sh' > /app/entrypoint.sh && \
echo 'moto_server -p 5000 -H 127.0.0.1 &' >> /app/entrypoint.sh && \
echo 'sleep 3' >> /app/entrypoint.sh && \
echo 'AWS_ENDPOINT_URL=http://127.0.0.1:5000 AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_DEFAULT_REGION=us-east-1 sh /app/init-all.sh' >> /app/entrypoint.sh && \
echo 'sleep 1' >> /app/entrypoint.sh && \
echo 'ASPNETCORE_URLS=http://127.0.0.1:8081 ASPNETCORE_HTTP_PORTS=8081 dotnet /app/worker/InventoryAlert.Worker.dll &' >> /app/entrypoint.sh && \
echo 'sleep 1' >> /app/entrypoint.sh && \
echo 'exec dotnet /app/api/InventoryAlert.Api.dll' >> /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
EXPOSE 8080
ENTRYPOINT ["/app/entrypoint.sh"]
LABEL maintainer="InventoryAlert Team"
LABEL version="1.0"
LABEL description="Consolidated API & Worker for Inventory Management System with built-in Moto emulator"