-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile.Spider
More file actions
67 lines (57 loc) · 2.59 KB
/
Dockerfile.Spider
File metadata and controls
67 lines (57 loc) · 2.59 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
# =============================================================================
# Dockerfile.Spider - Multi-stage build for NScrapy CLI
# =============================================================================
# Build stage: compile NScrapy.Cli and all dependencies
# Runtime stage: run with .NET 10.0 runtime
#
# Usage:
# docker build -f Dockerfile.Spider -t nscrapy-spider .
# docker run nscrapy-spider run MySpider --role spider --distributed
#
# Environment variables (override CLI args):
# REDIS_HOST - Redis host address
# REDIS_PORT - Redis port (default: 6379)
# REDIS_PASSWORD - Redis password
# REDIS_USESSL - Use SSL for Redis ("true" / "false")
# NSCRAPY_REDIS_HOST - Same as REDIS_HOST (preferred)
# NSCRAPY_REDIS_PORT - Same as REDIS_PORT (preferred)
# =============================================================================
# ---- Build Stage ----
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy solution and project files first (layer caching optimisation)
COPY NScrapy.sln ./
COPY NScrapy.Cli/NScrapy.Cli.csproj NScrapy.Cli/
COPY NScrapy.Core/NScrapy.Core.csproj NScrapy.Core/
COPY NScrapy.Engine/NScrapy.Engine.csproj NScrapy.Engine/
COPY NScrapy.Infra/NScrapy.Infra.csproj NScrapy.Infra/
COPY NScrapy.Scheduler/NScrapy.Scheduler.csproj NScrapy.Scheduler/
COPY NScrapy.Spider/NScrapy.Spider.csproj NScrapy.Spider/
COPY NScrapy.Downloader/NScrapy.Downloader.csproj NScrapy.Downloader/
COPY NScrapy.Spider/NScrapy.Spider.csproj NScrapy.Spider/
# Restore all NuGet packages
RUN dotnet restore NScrapy.Cli/NScrapy.Cli.csproj
# Copy source code
COPY NScrapy.Cli/ NScrapy.Cli/
COPY NScrapy.Core/ NScrapy.Core/
COPY NScrapy.Engine/ NScrapy.Engine/
COPY NScrapy.Infra/ NScrapy.Infra/
COPY NScrapy.Scheduler/ NScrapy.Scheduler/
COPY NScrapy.Spider/ NScrapy.Spider/
COPY NScrapy.Downloader/ NScrapy.Downloader/
# Build and publish CLI
WORKDIR /src/NScrapy.Cli
RUN dotnet publish -c Release --no-restore -o /app/publish -p:PublishSingleFile=false
# ---- Runtime Stage ----
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
# Copy published output from build stage
COPY --from=build /app/publish .
# Copy log4net config so logging works inside the container
COPY NScrapy.Infra/log4net.config ./ 2>/dev/null || true
# Environment defaults
ENV DOTNET_RUNNING_IN_CONTAINER=true
ENV ASPNETCORE_URLS=http://+:80
# Entry point: run the CLI
# Usage: docker run nscrapy-spider run MySpider --role spider --distributed
ENTRYPOINT ["nscrapy"]