-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image Loader Service 구성 #35
Comments
docker 기반 di 서비스 구성
// Program.cs
using DockerDIService.PrintService;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var build = new ConfigurationBuilder();
build.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", optional: true)
.AddEnvironmentVariables();
var host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddTransient<IPrint, PrintConsole>();
})
.Build();
var printService = host.Services.GetRequiredService<IPrint>();
printService.Print("Hello World!"); public interface IPrint
{
public void Print(string message);
}
public class PrintConsole : IPrint
{
public void Print(string message) =>
Console.WriteLine(message);
}
|
docker 기반 grpc 서비스 구성
using DockerGrpcServer.Protos;
using Grpc.Core;
namespace DockerGrpcServer.Services;
public class HelloService : Hello.HelloBase
{
public HelloService() { }
public override async Task<HelloReply> Hello(HelloRequest request, ServerCallContext context)
{
await Task.CompletedTask;
return new HelloReply() { Reply = "Hello World!" };
}
} using DockerGrpcServer.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddGrpc();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.MapGrpcService<HelloService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.Run();
|
docker 기반 grpc 서비스 2개간 통신 구성
Docker-Compose내부 외부 포트 설정 방법
# Server launchSettings.json의 https를 확인합니다.
# Local 연결의 경우
"applicationUrl": "https://localhost:63461;http://localhost:63462"
# Docker 연결의 경우
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
# client appsettings.json
{
"GrpcSettings": {
"ServerUrl": "https://dockergrpcserver:63461"
}
}
[tip] 일반 프로젝트 도커화 |
docker 기반 grpc 서비스 2개간 통신 구성 (서버 - 서버)
|
Docker db 구성Docker Project 관리법
services:
dockerdb.platform.db.postgre:
build:
dockerfile: Docker DB/DockerDB.Platform.DB/Postgre/Dockerfile # 파일 지정 방법
build: Docker DB/DockerDB.Platform.DB/Postgre/ # 디렉토리 지정 방법
ports:
- "5432:5432"
services:
dockerdb.platform.db.postgre:
image: postgres:latest
environment:
POSTGRES_DB: ImageHandlerServiceDB
POSTGRES_USER: postgres
POSTGRES_PASSWORD: @@@@@
ports:
- "5432:5432" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
진행 과정
기초
서비스 구성
서비스 구현
모니터링 구현
The text was updated successfully, but these errors were encountered: