Skip to content

Commit f5d2a01

Browse files
authored
Merge pull request #206 from philnach/dockerfix
Fix Docker container to properly build dmt Docker container using the same steps as the release build.
2 parents 1dc388e + 2bb1170 commit f5d2a01

File tree

1 file changed

+164
-22
lines changed

1 file changed

+164
-22
lines changed

Dockerfile

Lines changed: 164 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
33
WORKDIR /src
44

5+
# Set build arguments
6+
ARG RUNTIME=linux-x64
7+
ARG BUILD_VERSION=1.0.0
8+
59
# Copy solution file and project files
610
COPY ["CosmosDbDataMigrationTool.sln", "."]
711
COPY ["Directory.Packages.props", "."]
@@ -10,33 +14,171 @@ COPY ["Interfaces/", "Interfaces/"]
1014
COPY ["Extensions/", "Extensions/"]
1115

1216
# Restore dependencies
13-
# Increase the timeout and number of retries for NuGet
14-
RUN dotnet nuget list source | grep -q 'nuget.org' || dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
15-
ENV NUGET_PACKAGES=/nuget-packages
16-
ENV NUGET_HTTP_CACHE_PATH=/nuget-http-cache
17-
RUN mkdir -p /nuget-packages /nuget-http-cache
18-
19-
# Restore and build the main project and the core project
20-
RUN dotnet restore "Core/Cosmos.DataTransfer.Core/Cosmos.DataTransfer.Core.csproj" --disable-parallel
21-
RUN dotnet build "Core/Cosmos.DataTransfer.Core/Cosmos.DataTransfer.Core.csproj" -c Release -o /app/build/Core --no-restore
22-
RUN dotnet publish "Core/Cosmos.DataTransfer.Core/Cosmos.DataTransfer.Core.csproj" -c Release -o /app/publish/Core --no-restore
23-
24-
# Build and publish ALL extensions
25-
RUN find Extensions -name "*.csproj" | grep -v "UnitTests" | xargs -I {} sh -c 'dotnet publish "{}" -c Release -o /app/publish/Core/Extensions || echo "Skipping $(basename $(dirname {}))"'
26-
27-
# Runtime stage
28-
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
17+
RUN dotnet restore "Core/Cosmos.DataTransfer.Core/Cosmos.DataTransfer.Core.csproj"
18+
19+
# Build Core app package (self-contained)
20+
RUN dotnet publish \
21+
Core/Cosmos.DataTransfer.Core/Cosmos.DataTransfer.Core.csproj \
22+
--configuration Release \
23+
--output /app/${RUNTIME} \
24+
--self-contained true \
25+
--runtime ${RUNTIME} \
26+
-p:PublishSingleFile=true \
27+
-p:DebugType=embedded \
28+
-p:EnableCompressionInSingleFile=true \
29+
-p:PublishReadyToRun=false \
30+
-p:PublishTrimmed=false \
31+
-p:Version=${BUILD_VERSION}
32+
33+
# Build Cosmos Extension
34+
RUN dotnet publish \
35+
Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/Cosmos.DataTransfer.CosmosExtension.csproj \
36+
--configuration Release \
37+
--output /app/${RUNTIME}/Extensions \
38+
--self-contained false \
39+
--runtime ${RUNTIME} \
40+
-p:PublishSingleFile=false \
41+
-p:DebugType=embedded \
42+
-p:EnableCompressionInSingleFile=true \
43+
-p:PublishReadyToRun=false \
44+
-p:PublishTrimmed=false \
45+
-p:Version=${BUILD_VERSION}
46+
47+
# Build JSON Extension
48+
RUN dotnet publish \
49+
Extensions/Json/Cosmos.DataTransfer.JsonExtension/Cosmos.DataTransfer.JsonExtension.csproj \
50+
--configuration Release \
51+
--output /app/${RUNTIME}/Extensions \
52+
--self-contained false \
53+
--runtime ${RUNTIME} \
54+
-p:PublishSingleFile=false \
55+
-p:DebugType=embedded \
56+
-p:EnableCompressionInSingleFile=true \
57+
-p:PublishReadyToRun=false \
58+
-p:PublishTrimmed=false \
59+
-p:Version=${BUILD_VERSION}
60+
61+
# Build Azure Table Extension
62+
RUN dotnet publish \
63+
Extensions/AzureTableAPI/Cosmos.DataTransfer.AzureTableAPIExtension/Cosmos.DataTransfer.AzureTableAPIExtension.csproj \
64+
--configuration Release \
65+
--output /app/${RUNTIME}/Extensions \
66+
--self-contained false \
67+
--runtime ${RUNTIME} \
68+
-p:PublishSingleFile=false \
69+
-p:DebugType=embedded \
70+
-p:EnableCompressionInSingleFile=true \
71+
-p:PublishReadyToRun=false \
72+
-p:PublishTrimmed=false \
73+
-p:Version=${BUILD_VERSION}
74+
75+
# Build Mongo Extension
76+
RUN dotnet publish \
77+
Extensions/Mongo/Cosmos.DataTransfer.MongoExtension/Cosmos.DataTransfer.MongoExtension.csproj \
78+
--configuration Release \
79+
--output /app/${RUNTIME}/Extensions \
80+
--self-contained false \
81+
--runtime ${RUNTIME} \
82+
-p:PublishSingleFile=false \
83+
-p:DebugType=embedded \
84+
-p:EnableCompressionInSingleFile=true \
85+
-p:PublishReadyToRun=false \
86+
-p:PublishTrimmed=false \
87+
-p:Version=${BUILD_VERSION}
88+
89+
# Build SQL Server Extension
90+
RUN dotnet publish \
91+
Extensions/SqlServer/Cosmos.DataTransfer.SqlServerExtension/Cosmos.DataTransfer.SqlServerExtension.csproj \
92+
--configuration Release \
93+
--output /app/${RUNTIME}/Extensions \
94+
--self-contained false \
95+
--runtime ${RUNTIME} \
96+
-p:PublishSingleFile=false \
97+
-p:DebugType=embedded \
98+
-p:EnableCompressionInSingleFile=true \
99+
-p:PublishReadyToRun=false \
100+
-p:PublishTrimmed=false \
101+
-p:Version=${BUILD_VERSION}
102+
103+
# Build Parquet Extension
104+
RUN dotnet publish \
105+
Extensions/Parquet/Cosmos.DataTransfer.ParquetExtension/Cosmos.DataTransfer.ParquetExtension.csproj \
106+
--configuration Release \
107+
--output /app/${RUNTIME}/Extensions \
108+
--self-contained false \
109+
--runtime ${RUNTIME} \
110+
-p:PublishSingleFile=false \
111+
-p:DebugType=embedded \
112+
-p:EnableCompressionInSingleFile=true \
113+
-p:PublishReadyToRun=false \
114+
-p:PublishTrimmed=false \
115+
-p:Version=${BUILD_VERSION}
116+
117+
# Build Cognitive Search Extension
118+
RUN dotnet publish \
119+
Extensions/CognitiveSearch/Cosmos.DataTransfer.CognitiveSearchExtension/Cosmos.DataTransfer.CognitiveSearchExtension.csproj \
120+
--configuration Release \
121+
--output /app/${RUNTIME}/Extensions \
122+
--self-contained false \
123+
--runtime ${RUNTIME} \
124+
-p:PublishSingleFile=false \
125+
-p:DebugType=embedded \
126+
-p:EnableCompressionInSingleFile=true \
127+
-p:PublishReadyToRun=false \
128+
-p:PublishTrimmed=false \
129+
-p:Version=${BUILD_VERSION}
130+
131+
# Build CSV Extension
132+
RUN dotnet publish \
133+
Extensions/Csv/Cosmos.DataTransfer.CsvExtension/Cosmos.DataTransfer.CsvExtension.csproj \
134+
--configuration Release \
135+
--output /app/${RUNTIME}/Extensions \
136+
--self-contained false \
137+
--runtime ${RUNTIME} \
138+
-p:PublishSingleFile=false \
139+
-p:DebugType=embedded \
140+
-p:EnableCompressionInSingleFile=true \
141+
-p:PublishReadyToRun=false \
142+
-p:PublishTrimmed=false \
143+
-p:Version=${BUILD_VERSION}
144+
145+
# Build PostgreSQL Extension
146+
RUN dotnet publish \
147+
Extensions/PostgreSQL/Cosmos.DataTransfer.PostgresqlExtension.csproj \
148+
--configuration Release \
149+
--output /app/${RUNTIME}/Extensions \
150+
--self-contained false \
151+
--runtime ${RUNTIME} \
152+
-p:PublishSingleFile=false \
153+
-p:DebugType=embedded \
154+
-p:EnableCompressionInSingleFile=true \
155+
-p:PublishReadyToRun=false \
156+
-p:PublishTrimmed=false \
157+
-p:Version=${BUILD_VERSION}
158+
159+
# Runtime stage - use minimal base image since we have self-contained build
160+
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0 AS runtime
29161
WORKDIR /app
30162

31-
# Copy published files from build stage
32-
COPY --from=build /app/publish/Core ./
163+
# Enable this section for local development verification to use Microsoft Entra ID authentication
164+
# Install curl and Azure CLI
165+
# RUN apt-get clean && apt-get update
166+
# RUN apt install curl -y
167+
# RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
168+
169+
# Copy the built application
170+
ARG RUNTIME=linux-x64
171+
COPY --from=build /app/${RUNTIME} ./
172+
173+
# Verify the contents of the final image
174+
RUN echo "=== Final image contents ===" && ls -la ./ && echo "=== Extensions directory ===" && ls -la ./Extensions/ || echo "No Extensions directory"
33175

34176
# Create volumes for configuration and data
35177
VOLUME /config
36178
VOLUME /data
37179

38-
# Optional volume for custom extensions
39-
VOLUME /extensions
180+
# Make the executable file executable (for Linux)
181+
RUN chmod +x dmt
40182

41-
# Set the entrypoint
42-
ENTRYPOINT ["dotnet", "dmt.dll"]
183+
# Set the entrypoint to the self-contained executable
184+
ENTRYPOINT ["./dmt"]

0 commit comments

Comments
 (0)