Skip to content

Commit

Permalink
Added docker compose support
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbeuk committed Nov 11, 2022
1 parent 4fab020 commit e30bfaf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.9'
services:
model-scanner:
container_name: civitai-model-scanner
build:
context: ./model-scanner/
dockerfile: Dockerfile
orchestrator:
container_name: civitai-model-scanner-orchestrator
build:
context: ./orchestrator/
dockerfile: Dockerfile
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- "80:80"
depends_on:
- model-scanner
7 changes: 7 additions & 0 deletions orchestrator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base

RUN apt-get update && \
apt-get -qy full-upgrade && \
apt-get install -qy curl && \
apt-get install -qy curl && \
curl -sSL https://get.docker.com/ | sh

WORKDIR /app
EXPOSE 80
EXPOSE 443
Expand Down
12 changes: 10 additions & 2 deletions orchestrator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

var process = new Process
{
StartInfo = new ProcessStartInfo("docker", $"run -it --rm civitai-model-scanner {modelUrl}")
StartInfo = new ProcessStartInfo("docker", $"run --rm civitai-model-scanner {modelUrl}")
{
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
Expand Down Expand Up @@ -75,7 +75,15 @@
await foreach (var (callbackUrl, result) in callbackQueueChannel.Reader.ReadAllAsync())
{
logger.LogInformation("Invoking {callbackUrl} with result {result}", callbackUrl, result);
await httpClient.PostAsync(callbackUrl, new StringContent(result));

try
{
await httpClient.PostAsync(callbackUrl, new StringContent(result));
}
catch(Exception ex)
{
logger.LogError(ex, "Exception raised during callback, no retry is configured. The result will be ignored");
}
}
});

Expand Down

0 comments on commit e30bfaf

Please sign in to comment.