-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (39 loc) · 2.24 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (39 loc) · 2.24 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
# ─────────────────────────────────────────────────────────────────────
# AŞAMA 1 – Base image: SDK ile derleme
# ─────────────────────────────────────────────────────────────────────
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Önce sadece .csproj'ları kopyala → layer cache'i maksimize eder
COPY CoderAI.sln ./
COPY CoderAI.Api/CoderAI.Api.csproj CoderAI.Api/
COPY CoderAI.Application/CoderAI.Application.csproj CoderAI.Application/
COPY CoderAI.Domain/CoderAI.Domain.csproj CoderAI.Domain/
COPY CoderAI.Infrastructure/CoderAI.Infrastructure.csproj CoderAI.Infrastructure/
# NuGet restore (sadece csproj katmanı değiştiyse çalışır)
RUN dotnet restore CoderAI.sln
# Kaynak kodu kopyala
COPY . .
# Release build — sadece API projesini yayınla
RUN dotnet publish CoderAI.Api/CoderAI.Api.csproj \
-c Release \
-o /app/publish \
--no-restore \
/p:UseAppHost=false
# ─────────────────────────────────────────────────────────────────────
# AŞAMA 2 – Runtime image: sadece runtime (200 MB tasarruf)
# ─────────────────────────────────────────────────────────────────────
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
# Güvenlik: root olmayan kullanıcı oluştur
RUN adduser --disabled-password --gecos "" appuser \
&& chown -R appuser /app
USER appuser
# Yayınlanan dosyaları kopyala
COPY --from=build --chown=appuser:appuser /app/publish .
# SignalR / WebSocket için Kestrel ayarı (Railway/Render HTTP → HTTPS proxy yapar)
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production
# Port (Railway bu değişkeni override edebilir → EXPOSE sembolik)
EXPOSE 8080
# Giriş noktası
ENTRYPOINT ["dotnet", "CoderAI.Api.dll"]