This repository was archived by the owner on Mar 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (27 loc) · 1.47 KB
/
Dockerfile
File metadata and controls
36 lines (27 loc) · 1.47 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
# Stage 1: Build the application
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH
WORKDIR /app
# Set the default environment to Development
ARG ENVIRONMENT=Development
ENV ASPNETCORE_ENVIRONMENT=${ENVIRONMENT}
# Copy the solution and project files
COPY weekplanner-api.sln ./
COPY GirafAPI/*.csproj ./GirafAPI/
COPY GirafAPI/Data/Migrations/*.cs ./GirafAPI/Data/Migrations/
COPY Giraf.UnitTests/*.csproj ./Giraf.UnitTests/
COPY Giraf.IntegrationTests/*.csproj ./Giraf.IntegrationTests/
# Restore dependencies for all projects in the solution
RUN dotnet restore weekplanner-api.sln
# Copy the entire source code for the projects
COPY . .
# Build each project individually with the architecture specified
RUN dotnet build ./GirafAPI/GirafAPI.csproj -c Release -o /app/build -a $TARGETARCH
RUN dotnet build ./Giraf.UnitTests/Giraf.UnitTests.csproj -c Release -o /app/build -a $TARGETARCH
RUN dotnet build ./Giraf.IntegrationTests/Giraf.IntegrationTests.csproj -c Release -o /app/build -a $TARGETARCH
# Publish the main application with the architecture specified
RUN dotnet publish ./GirafAPI/GirafAPI.csproj -c Release -o /app/publish -a $TARGETARCH --no-restore
# Expose the port for the app
EXPOSE 5171
# Set the entry point for development or production
ENTRYPOINT ["sh", "-c", "if [ \"$ASPNETCORE_ENVIRONMENT\" = 'Development' ]; then dotnet watch run --project GirafAPI/GirafAPI.csproj --urls http://+:5171; else dotnet /app/publish/GirafAPI.dll; fi"]