Skip to content

Commit

Permalink
Merge pull request #52 from skni-kod/feature/#30-seeder
Browse files Browse the repository at this point in the history
 seed data into database
  • Loading branch information
Comply5000 authored Dec 27, 2023
2 parents 4afbc88 + 78aa335 commit abb9c88
Show file tree
Hide file tree
Showing 19 changed files with 1,032 additions and 42 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["skit.API/skit.API.csproj", "skit.API/"]
COPY ["skit.Application/skit.Application.csproj", "skit.Application/"]
COPY ["skit.Core/skit.Core.csproj", "skit.Core/"]
COPY ["skit.Shared.Abstractions/skit.Shared.Abstractions.csproj", "skit.Shared.Abstractions/"]
COPY ["skit.Shared/skit.Shared.csproj", "skit.Shared/"]
COPY ["skit.Infrastructure/skit.Infrastructure.csproj", "skit.Infrastructure/"]
RUN dotnet restore "skit.API/skit.API.csproj"
COPY . .
WORKDIR "/src/skit.API"
RUN dotnet build "skit.API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "skit.API.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "skit.API.dll"]
52 changes: 52 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '3.9'

services:
api:
image: skit
build:
context: .
dockerfile: Dockerfile
depends_on:
- createBucket
ports:
- '5000:80'

db:
image: postgres
ports:
- '6000:5432'
environment:
POSTGRES_DB: skit-database
POSTGRES_USER: skit-user
POSTGRES_PASSWORD: 1qazXSW@
volumes:
- postgres-data:/var/lib/postgresql/data
depends_on:
- minio

minio:
image: minio/minio:latest
ports:
- '9000:9000'
- '9001:9001'
volumes:
- minio_data:/data
environment:
- MINIO_ROOT_USER=admin
- MINIO_ROOT_PASSWORD=1qazXSW@
command: server --console-address ":9001" --address ":9000" /data

createBucket:
image: minio/mc
depends_on:
- db
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:9000 admin 1qazXSW@;
/usr/bin/mc mb myminio/skit;
exit 0;"
volumes:
minio_data:
driver: local
postgres-data:
35 changes: 0 additions & 35 deletions skit.API/Controllers/Areas/Dev/SeederController.cs

This file was deleted.

5 changes: 5 additions & 0 deletions skit.API/skit.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<UserSecretsId>58188e14-edd7-4d56-9b90-210b5fe01426</UserSecretsId>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
Expand All @@ -28,4 +29,8 @@
<ProjectReference Include="..\skit.Shared\skit.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\SeedData\Technologies\Images\" />
</ItemGroup>

</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions skit.API/wwwroot/SeedData/Technologies/technologies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"Name": "C#",
"ThumUrl": "qwer",
"PhotoPath": "csharp-photo.png"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

namespace skit.Application.Files.Commands.UploadFile;

public sealed record UploadFilCommand(IFormFile File, FileType Type) : IRequest<UploadFileResponse>;
public sealed record UploadFileCommand(IFormFile File, FileType Type) : IRequest<UploadFileResponse>;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace skit.Application.Files.Commands.UploadFile;

public sealed class UploadFileHandler : IRequestHandler<UploadFilCommand, UploadFileResponse>
public sealed class UploadFileHandler : IRequestHandler<UploadFileCommand, UploadFileResponse>
{
private readonly IFileRepository _fileRepository;
private readonly IS3StorageService _s3StorageService;
Expand All @@ -18,7 +18,7 @@ public UploadFileHandler(IFileRepository fileRepository, IS3StorageService s3Sto
_s3StorageService = s3StorageService;
}

public async Task<UploadFileResponse> Handle(UploadFilCommand request, CancellationToken cancellationToken)
public async Task<UploadFileResponse> Handle(UploadFileCommand request, CancellationToken cancellationToken)
{
var s3Key = await _s3StorageService.UploadFileAsync(request.File, cancellationToken);

Expand Down
13 changes: 9 additions & 4 deletions skit.Core/Technologies/Entities/Technology.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using skit.Core.Offers.Entities;
using skit.Core.Files.Entities;
using skit.Core.Offers.Entities;
using skit.Shared.Abstractions.Entities;

namespace skit.Core.Technologies.Entities;
Expand All @@ -8,21 +9,25 @@ public sealed class Technology : Entity
public string Name { get; private set; }
public string? ThumUrl { get; private set; }

public Guid? PhotoId { get; set; }
public SystemFile Photo { get; set; }

private List<Offer> _offers = new();
public IReadOnlyCollection<Offer> Offers => _offers;

private Technology()

Check warning on line 18 in skit.Core/Technologies/Entities/Technology.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
}

private Technology(string name, string? thumUrl)
private Technology(string name, string? thumUrl, Guid? photoId)
{
Name = name;
ThumUrl = thumUrl;
PhotoId = photoId;
}

public static Technology Create(string name, string? thumUrl)
=> new(name, thumUrl);
public static Technology Create(string name, string? thumUrl, Guid? photoId)
=> new(name, thumUrl, photoId);

public void Update(string name, string? thumUrl)
{
Expand Down
Loading

0 comments on commit abb9c88

Please sign in to comment.