Skip to content

Commit 1c9c39b

Browse files
committed
Add database initialization and seeding scripts for contacts management
- Created 01-init-db.sh to initialize the contacts database if it doesn't exist. - Added 02-seed-data.sql to create necessary tables and insert initial data including users, roles, permissions, and sample contacts. - Implemented foreign key constraints and unique constraints for data integrity. - Seeded initial roles (Admin, Reader, Editor) and assigned permissions accordingly.
1 parent 6bbce05 commit 1c9c39b

File tree

183 files changed

+361
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+361
-22
lines changed

backend/src/Contact.Api.sln renamed to Contact.Api.sln

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.11.35208.52
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.0.11222.15 d18.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contact.Api", "Contact.Api\Contact.Api.csproj", "{E71B9B65-032D-4CC7-86B9-4712CC4E4B8E}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contact.Api", "backend\Contact.Api\Contact.Api.csproj", "{E71B9B65-032D-4CC7-86B9-4712CC4E4B8E}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Infrastructure", "Contact.Infrastructure\Contact.Infrastructure.csproj", "{AD68A223-AFC1-4A11-B056-82D1DEF146F0}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Infrastructure", "backend\Contact.Infrastructure\Contact.Infrastructure.csproj", "{AD68A223-AFC1-4A11-B056-82D1DEF146F0}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Application", "Contact.Application\Contact.Application.csproj", "{42EF202E-6AA6-42B8-9AE6-E4B06C36EB36}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Application", "backend\Contact.Application\Contact.Application.csproj", "{42EF202E-6AA6-42B8-9AE6-E4B06C36EB36}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Domain", "Contact.Domain\Contact.Domain.csproj", "{41338193-C8C7-4348-9011-C7D2C437B36C}"
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Domain", "backend\Contact.Domain\Contact.Domain.csproj", "{41338193-C8C7-4348-9011-C7D2C437B36C}"
1313
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Common", "Contact.Common\Contact.Common.csproj", "{32C9230B-EE1E-4F3C-806F-685EB36C55F4}"
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.Common", "backend\Contact.Common\Contact.Common.csproj", "{32C9230B-EE1E-4F3C-806F-685EB36C55F4}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.AppHost", "aspire\AppHost\Contact.AppHost.csproj", "{9E5B8B78-8F0B-403E-A7AA-71A75C60D128}"
17+
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contact.ServiceDefaults", "aspire\ServiceDefaults\Contact.ServiceDefaults.csproj", "{B649DAF0-42CE-92EA-0381-374285B927BF}"
1519
EndProject
1620
Global
1721
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,6 +43,14 @@ Global
3943
{32C9230B-EE1E-4F3C-806F-685EB36C55F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
4044
{32C9230B-EE1E-4F3C-806F-685EB36C55F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
4145
{32C9230B-EE1E-4F3C-806F-685EB36C55F4}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{9E5B8B78-8F0B-403E-A7AA-71A75C60D128}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{9E5B8B78-8F0B-403E-A7AA-71A75C60D128}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{9E5B8B78-8F0B-403E-A7AA-71A75C60D128}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{9E5B8B78-8F0B-403E-A7AA-71A75C60D128}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{B649DAF0-42CE-92EA-0381-374285B927BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{B649DAF0-42CE-92EA-0381-374285B927BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{B649DAF0-42CE-92EA-0381-374285B927BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{B649DAF0-42CE-92EA-0381-374285B927BF}.Release|Any CPU.Build.0 = Release|Any CPU
4254
EndGlobalSection
4355
GlobalSection(SolutionProperties) = preSolution
4456
HideSolutionNode = FALSE

Dockerfile.api

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
2+
WORKDIR /app
3+
EXPOSE 8000
4+
ENV ASPNETCORE_URLS=http://+:8000
5+
RUN groupadd -g 2000 dotnet \
6+
&& useradd -m -u 2000 -g 2000 dotnet
7+
USER dotnet
8+
9+
# This stage is used to build the service project
10+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
11+
ARG BUILD_CONFIGURATION=Release
12+
ARG DOTNET_SKIP_POLICY_LOADING=true
13+
WORKDIR /src
14+
COPY ["backend/Contact.Api/Contact.Api.csproj", "backend/Contact.Api/"]
15+
COPY ["backend/Contact.Application/Contact.Application.csproj", "backend/Contact.Application/"]
16+
COPY ["backend/Contact.Domain/Contact.Domain.csproj", "backend/Contact.Domain/"]
17+
COPY ["backend/Contact.Infrastructure/Contact.Infrastructure.csproj", "backend/Contact.Infrastructure/"]
18+
COPY ["backend/Contact.Common/Contact.Common.csproj", "backend/Contact.Common/"]
19+
COPY ["aspire/ServiceDefaults/Contact.ServiceDefaults.csproj", "aspire/ServiceDefaults/"]
20+
21+
RUN dotnet restore "./backend/Contact.Api/Contact.Api.csproj"
22+
COPY backend/ backend/
23+
COPY aspire/ServiceDefaults/ aspire/ServiceDefaults/
24+
WORKDIR "/src/backend/Contact.Api"
25+
RUN dotnet build "./Contact.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
26+
27+
RUN ls /app/build
28+
29+
# This stage is used to publish the service project to be copied to the final stage
30+
FROM build AS publish
31+
ARG BUILD_CONFIGURATION=Release
32+
RUN dotnet publish "./Contact.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
33+
34+
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
35+
FROM base AS final
36+
WORKDIR /app
37+
# COPY --from=publish /app/publish/Contact.Api.dll .
38+
COPY --from=publish /app/publish .
39+
ENTRYPOINT ["dotnet", "Contact.Api.dll"]
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)