-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (54 loc) · 2.52 KB
/
Dockerfile
File metadata and controls
68 lines (54 loc) · 2.52 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
# Multi-stage build for optimized image size
# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ENV BUILD_VERSION=1.1.0
WORKDIR /src
# Copy solution and project files
COPY Elle.TicimaxFeed.sln ./
COPY src/Elle.TicimaxFeed.Domain/Elle.TicimaxFeed.Domain.csproj ./src/Elle.TicimaxFeed.Domain/
COPY src/Elle.TicimaxFeed.Application/Elle.TicimaxFeed.Application.csproj ./src/Elle.TicimaxFeed.Application/
COPY src/Elle.TicimaxFeed.Infrastructure/Elle.TicimaxFeed.Infrastructure.csproj ./src/Elle.TicimaxFeed.Infrastructure/
COPY src/Elle.TicimaxFeed.Worker/Elle.TicimaxFeed.Worker.csproj ./src/Elle.TicimaxFeed.Worker/
COPY tests/Elle.TicimaxFeed.Tests/Elle.TicimaxFeed.Tests.csproj ./tests/Elle.TicimaxFeed.Tests/
# Restore dependencies
RUN dotnet restore
# Copy source code
COPY . .
# Build and publish
WORKDIR /src/src/Elle.TicimaxFeed.Worker
RUN dotnet publish -c Release -o /app/publish --no-restore
# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
# Create non-root user for security
RUN useradd -m -u 1000 appuser
# Copy published output from build stage
COPY --from=build --chown=appuser:appuser /app/publish .
# Create entrypoint script to fix volume permissions at runtime
RUN echo '#!/bin/bash' > /docker-entrypoint.sh && \
echo 'set -e' >> /docker-entrypoint.sh && \
echo '' >> /docker-entrypoint.sh && \
echo '# Fix permissions for mounted volumes' >> /docker-entrypoint.sh && \
echo 'mkdir -p /app/feeds /app/logs' >> /docker-entrypoint.sh && \
echo 'chown -R appuser:appuser /app/feeds /app/logs 2>/dev/null || true' >> /docker-entrypoint.sh && \
echo '' >> /docker-entrypoint.sh && \
echo '# Switch to appuser and run the command' >> /docker-entrypoint.sh && \
echo 'exec gosu appuser "$@"' >> /docker-entrypoint.sh && \
chmod +x /docker-entrypoint.sh
# Install gosu for safe user switching and curl for healthcheck
RUN apt-get update && \
apt-get install -y --no-install-recommends gosu curl && \
rm -rf /var/lib/apt/lists/* && \
gosu nobody true
# Create volumes for persistent data
VOLUME ["/app/feeds", "/app/logs"]
# Environment variables (will be overridden by Coolify)
ENV DOTNET_ENVIRONMENT=Production
ENV ASPNETCORE_ENVIRONMENT=Production
# Expose HTTP port for feed serving
EXPOSE 80
# Note: Healthcheck removed - not needed for background worker services
# Coolify healthcheck is disabled in UI settings
# Use entrypoint script to fix permissions before starting
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["dotnet", "Elle.TicimaxFeed.Worker.dll"]