-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
116 lines (97 loc) · 4.44 KB
/
Dockerfile
File metadata and controls
116 lines (97 loc) · 4.44 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# =============================================================================
# Dockerfile for Route4Me C# SDK Testing Environment
#
# This Dockerfile creates a containerized environment for building and testing
# the Route4Me C# SDK, based on the Travis CI configuration.
#
# Usage:
# Build: docker build -t route4me-sdk-test .
# Run tests: docker run --rm route4me-sdk-test
# Interactive shell: docker run -it --rm route4me-sdk-test /bin/bash
#
# =============================================================================
# Use the official .NET 10.0 SDK image as base
# This provides both build and runtime capabilities for .NET 10.0 projects
# Specify platform to avoid QEMU emulation issues on Apple Silicon
FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:10.0 AS base
# Set environment variables for non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Install additional dependencies that might be needed for testing
# and development tools
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
unzip \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /app
# Copy the entire project structure
# This includes all source code, test projects, and data files
COPY . .
# =============================================================================
# Build Stage
# =============================================================================
FROM base AS build
# Restore dependencies for the entire solution
# This matches the Travis CI command: dotnet restore ./route4me-csharp-sdk/Route4MeSDK.sln
RUN dotnet restore ./route4me-csharp-sdk/Route4MeSDK.sln
# Build the SDK library
# Note: SDK library targets netstandard2.0, so no framework override needed
RUN dotnet build -v q -c Release ./route4me-csharp-sdk/Route4MeSDKLibrary/Route4MeSDKLibrary.csproj
# Build the unit test projects
# Note: Test projects target net10.0, so no framework override needed
RUN dotnet build -v q -c Release ./route4me-csharp-sdk/Route4MeSDKUnitTest/Route4MeSDKUnitTest.csproj
RUN dotnet build -v q -c Release ./route4me-csharp-sdk/Route4MeSdkV5UnitTest/Route4MeSdkV5UnitTest.csproj
# =============================================================================
# Test Stage
# =============================================================================
FROM build AS test
# Set the working directory to the SDK folder
WORKDIR /app/route4me-csharp-sdk
# Run the unit tests
# Note: Test projects target net10.0, so no framework override needed
RUN dotnet test -v n -p:ParallelizeTestCollections=false -c Release --filter Category!=Beacon ./Route4MeSDKUnitTest/Route4MeSDKUnitTest.csproj
# Run the V5 unit tests as well
RUN dotnet test -v n -p:ParallelizeTestCollections=false -c Release ./Route4MeSdkV5UnitTest/Route4MeSdkV5UnitTest.csproj
# =============================================================================
# Development Stage
# =============================================================================
FROM build AS development
# Set the working directory to the SDK folder
WORKDIR /app/route4me-csharp-sdk
# Create a script to run all tests
RUN echo '#!/bin/bash\n\
echo "Running Route4Me SDK Tests..."\n\
echo "================================"\n\
\n\
echo "Running Unit Tests (excluding Beacon category)..."\n\
dotnet test -v n -p:ParallelizeTestCollections=false -c Release --filter Category!=Beacon ./Route4MeSDKUnitTest/Route4MeSDKUnitTest.csproj\n\
\n\
echo "Running V5 Unit Tests..."\n\
dotnet test -v n -p:ParallelizeTestCollections=false -c Release ./Route4MeSdkV5UnitTest/Route4MeSdkV5UnitTest.csproj\n\
\n\
echo "All tests completed!"\n\
' > /usr/local/bin/run-tests.sh && chmod +x /usr/local/bin/run-tests.sh
# Create a script to build the solution
RUN echo '#!/bin/bash\n\
echo "Building Route4Me SDK..."\n\
echo "========================"\n\
\n\
echo "Restoring dependencies..."\n\
dotnet restore ./Route4MeSDK.sln\n\
\n\
echo "Building SDK Library..."\n\
dotnet build -v q -c Release ./Route4MeSDKLibrary/Route4MeSDKLibrary.csproj\n\
\n\
echo "Building Unit Test projects..."\n\
dotnet build -v q -c Release ./Route4MeSDKUnitTest/Route4MeSDKUnitTest.csproj\n\
dotnet build -v q -c Release ./Route4MeSdkV5UnitTest/Route4MeSdkV5UnitTest.csproj\n\
\n\
echo "Build completed!"\n\
' > /usr/local/bin/build-sdk.sh && chmod +x /usr/local/bin/build-sdk.sh
# Set the default command to run tests
# CMD ["/usr/local/bin/run-tests.sh"]