Skip to content

Commit eef7c4e

Browse files
committed
dockerfiles and script
1 parent 4bad000 commit eef7c4e

4 files changed

Lines changed: 94 additions & 20 deletions

File tree

.dockerignore

Lines changed: 0 additions & 18 deletions
This file was deleted.

scripts/Build-Docker.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ param (
2424
[string]$WorkingDirectory
2525
)
2626

27+
$ErrorActionPreference = "Stop"
28+
29+
$InitDirectory = Get-Location
30+
2731
Write-Output "Changing directory to $WorkingDirectory"
2832
Set-Location $WorkingDirectory
2933

@@ -45,12 +49,17 @@ Write-Output "ACR_GIT_VERSION_IMAGE: $ACR_GIT_VERSION_IMAGE"
4549
Write-Output "ACR_LATEST_VERSION_IMAGE: $ACR_LATEST_VERSION_IMAGE"
4650
Write-Output "ACR_SHA_IMAGE: $ACR_SHA_TAG"
4751

52+
$sw = [System.Diagnostics.Stopwatch]::StartNew()
53+
4854
# Build the Docker image
4955
docker build --build-arg FRONT_API_URL="$DockerBuildParameterUrl" `
5056
--build-arg VERSION="$gitVersion" `
5157
-t "$GIT_VERSION_IMAGE" `
5258
-f "$DockerfilePath" .
5359

60+
$sw.Stop()
61+
Write-Host "Docker build occupied: $($sw.Elapsed.TotalSeconds)"
62+
5463
# Tag the images
5564
docker tag "$GIT_VERSION_IMAGE" "$LATEST_VERSION_IMAGE"
5665
docker tag "$GIT_VERSION_IMAGE" "$ACR_LATEST_VERSION_IMAGE"
@@ -61,6 +70,10 @@ docker tag "$GIT_VERSION_IMAGE" "$ACR_SHA_TAG"
6170
# List images
6271
docker image ls
6372

73+
Write-Host "Set location back to $InitDirectory..."
74+
75+
Set-Location $InitDirectory
76+
6477
# EXAMPLE CALL
6578
#.\Build-Docker.ps1 `
6679
# -DockerRegistryUrl "docker.io/kaminome"`
@@ -69,4 +82,5 @@ docker image ls
6982
# -DockerBuildParameterUrl "https://auth-eventtriangle.razumovsky.me/" `
7083
# -DockerfilePath "E:\RiderProjects\02_DOTNET_PROJECTS\EventTriangleAPI\src\authorization\Dockerfile" `
7184
# -GitVersion "1.0.0" `
85+
# -CommitSha "8e33ce9" `
7286
# -WorkingDirectory "E:\RiderProjects\02_DOTNET_PROJECTS\EventTriangleAPI\src"

src/.dockerignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# =========================
2+
# Build outputs (.NET)
3+
# =========================
4+
**/bin/
5+
**/obj/
6+
7+
# =========================
8+
# Node / frontend
9+
# =========================
10+
**/node_modules/
11+
**/dist/
12+
**/build/
13+
14+
# =========================
15+
# IDE / editor
16+
# =========================
17+
.vscode/
18+
.idea/
19+
*.suo
20+
*.user
21+
*.userosscache
22+
*.sln.docstates
23+
24+
# =========================
25+
# Git
26+
# =========================
27+
.git/
28+
.gitignore
29+
30+
# =========================
31+
# Logs / temp
32+
# =========================
33+
*.log
34+
*.tmp
35+
*.cache
36+
37+
# =========================
38+
# OS files
39+
# =========================
40+
.DS_Store
41+
Thumbs.db
42+
43+
# =========================
44+
# Tests (optional!)
45+
# =========================
46+
**/*Tests/
47+
**/*.Test*/

src/authorization/Dockerfile

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,69 @@
11
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
2+
3+
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
4+
25
WORKDIR /app
6+
37
EXPOSE 8080
48

5-
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
9+
#######################################################################################################
10+
# BUILD ANGULAR
11+
#######################################################################################################
612

713
FROM node:18.15.0-alpine AS angularBuild
14+
815
WORKDIR /angular
16+
917
COPY ["authorization/EventTriangle.Client/package.json", "EventTriangle.Client/"]
1018
COPY ["authorization/EventTriangle.Client/package-lock.json", "EventTriangle.Client/"]
19+
1120
WORKDIR "EventTriangle.Client"
21+
1222
RUN npm ci
23+
1324
WORKDIR /angular
25+
1426
COPY ["authorization/EventTriangle.Client", "EventTriangle.Client/"]
27+
1528
RUN npm install -g @angular/cli@15.2.7
29+
1630
WORKDIR "EventTriangle.Client"
31+
1732
ARG FRONT_API_URL
33+
1834
RUN sed -i "s|https://localhost:7000/|$FRONT_API_URL|" ./src/assets/config/config.json
35+
1936
RUN ng build --output-path "dist/client"
2037

38+
#######################################################################################################
39+
# BUILD DOTNET
40+
#######################################################################################################
41+
2142
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS publish
43+
2244
WORKDIR /src
45+
2346
COPY ["authorization/EventTriangleAPI.Authorization.BusinessLogic/EventTriangleAPI.Authorization.BusinessLogic.csproj", "authorization/EventTriangleAPI.Authorization.BusinessLogic/"]
2447
COPY ["authorization/EventTriangleAPI.Authorization.Domain/EventTriangleAPI.Authorization.Domain.csproj", "authorization/EventTriangleAPI.Authorization.Domain/"]
2548
COPY ["authorization/EventTriangleAPI.Authorization.Persistence/EventTriangleAPI.Authorization.Persistence.csproj", "authorization/EventTriangleAPI.Authorization.Persistence/"]
2649
COPY ["authorization/EventTriangleAPI.Authorization.Presentation/EventTriangleAPI.Authorization.Presentation.csproj", "authorization/EventTriangleAPI.Authorization.Presentation/"]
27-
COPY ["authorization/EventTriangleAPI.Authorization.UnitTests/EventTriangleAPI.Authorization.UnitTests.csproj", "authorization/EventTriangleAPI.Authorization.UnitTests/"]
2850
COPY ["shared/EventTriangleAPI.Shared.Application/EventTriangleAPI.Shared.Application.csproj", "shared/EventTriangleAPI.Shared.Application/"]
2951
COPY ["shared/EventTriangleAPI.Shared.DTO/EventTriangleAPI.Shared.DTO.csproj", "shared/EventTriangleAPI.Shared.DTO/"]
52+
3053
RUN dotnet restore "authorization/EventTriangleAPI.Authorization.Presentation/EventTriangleAPI.Authorization.Presentation.csproj"
54+
3155
COPY . .
56+
3257
WORKDIR "authorization/EventTriangleAPI.Authorization.Presentation"
58+
3359
ARG VERSION
60+
3461
RUN dotnet publish "EventTriangleAPI.Authorization.Presentation.csproj" -c Release -p:Version=$VERSION -o /app/publish /p:UseAppHost=false
3562

63+
#######################################################################################################
64+
# CREATE FINAL ARTIFACT
65+
#######################################################################################################
66+
3667
FROM base AS final
3768
WORKDIR /app
3869
COPY --from=publish /app/publish .

0 commit comments

Comments
 (0)