Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

fila de pedidos #21

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.x # Change to the desired .NET version
dotnet-version: 6.x

- name: Restore NuGet packages
run: dotnet restore test/**/*.csproj # Adjust the path if necessary
run: dotnet restore test/**/*.csproj

- name: Build
run: dotnet build test/**/*.csproj # Adjust the path if necessary
run: dotnet build test/**/*.csproj

- name: Test
run: dotnet test test/**/*.csproj # Adjust the path if necessary
run: dotnet test test/**/*.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker Image and Docker Compose
name: Build Docker Compose

on:
push:
Expand All @@ -22,11 +22,6 @@ jobs:
- name: Set up Docker
uses: docker/setup-buildx-action@v1

- name: Build Docker Image
run: |
cd src/TechLanches
docker build -t techlanches-image:latest . --no-cache

- name: Run Docker Compose Build
run: docker-compose -f docker-compose.yml build --no-cache

Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/dockerfile-api-build-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build API Docker Image

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker
uses: docker/setup-buildx-action@v1

- name: Build Docker Image
run: |
cd src/TechLanches
docker build -f Dockerfile.API -t techlanches-api-image:latest . --no-cache

- name: Clean up
run: docker system prune -af
31 changes: 31 additions & 0 deletions .github/workflows/dockerfile-worker-build-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build Worker Docker Image

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker
uses: docker/setup-buildx-action@v1

- name: Build Docker Image
run: |
cd src/TechLanches
docker build -f Dockerfile.Worker -t techlanches-worker-image:latest . --no-cache

- name: Clean up
run: docker system prune -af
15 changes: 14 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
webapi:
build:
context: ./src/TechLanches/
dockerfile: Dockerfile
dockerfile: Dockerfile.API
container_name: api-dotnet6
ports:
- "5050:80"
Expand All @@ -16,6 +16,19 @@ services:
depends_on:
- db

worker:
build:
context: ./src/TechLanches/
dockerfile: Dockerfile.Worker
container_name: worker-dotnet6
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionStrings__DefaultConnection=Server=db;Database=techlanches;User=sa;Password=Qwert@12345
networks:
- techlanches-network
depends_on:
- db

db:
image: mcr.microsoft.com/mssql/server:2019-latest
container_name: sql-server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ private static void ProdutosSeed(TechLanchesDbContext context)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace TechLanches.Adapter.SqlServer
{
public static class DatabaseConfig
{
public static void AddDatabaseConfiguration(
this IServiceCollection services,
IConfiguration configuration,
ServiceLifetime serviceLifetime = ServiceLifetime.Scoped)
{
if (services is null) throw new ArgumentNullException(nameof(services));

services.AddDbContext<TechLanchesDbContext>(config =>
{
config.UseSqlServer(configuration.GetConnectionString("DefaultConnection"));
},
serviceLifetime);
}

public static void UseDatabaseConfiguration(this IApplicationBuilder app)
{
if (app is null) throw new ArgumentNullException(nameof(app));

SetDatabaseDefaults(app.ApplicationServices);
}

public static void UseDatabaseConfiguration(this IServiceProvider serviceProvider)
{
if (serviceProvider is null) throw new ArgumentNullException(nameof(serviceProvider));

SetDatabaseDefaults(serviceProvider);
}

private static void SetDatabaseDefaults(IServiceProvider serviceProvider)
{
object locker = new();

lock (locker)
{
using var scope = serviceProvider.CreateScope();

var services = scope.ServiceProvider;

var context = services.GetRequiredService<TechLanchesDbContext>();

if (context.Database.GetPendingMigrations().Any())
{
context.Database.Migrate();
}

DataSeeder.Seed(context);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TechLanches.Application.DTOs;

namespace TechLanches.Adapter.SqlServer.EntityTypeConfigurations
{
public class FilaPedidoEntityTypeConfiguration : IEntityTypeConfiguration<FilaPedido>
{
public void Configure(EntityTypeBuilder<FilaPedido> builder)
{
builder.HasNoKey();
}
}
}
Loading
Loading