Use env var for transcoder url (#426)

This commit is contained in:
Zoe Roux 2024-04-20 13:19:22 +02:00 committed by GitHub
parent c46385d467
commit c2a519923a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 2 deletions

View File

@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>. // along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using AspNetCore.Proxy; using AspNetCore.Proxy;
using AspNetCore.Proxy.Options; using AspNetCore.Proxy.Options;
@ -28,6 +29,12 @@ using Microsoft.AspNetCore.Mvc;
namespace Kyoo.Core.Api; namespace Kyoo.Core.Api;
public static class Transcoder
{
public static string TranscoderUrl =
Environment.GetEnvironmentVariable("TRANSCODER_URL") ?? "http://transcoder:7666";
}
public abstract class TranscoderApi<T>(IRepository<T> repository, IThumbnailsManager thumbs) public abstract class TranscoderApi<T>(IRepository<T> repository, IThumbnailsManager thumbs)
: CrudThumbsApi<T>(repository, thumbs) : CrudThumbsApi<T>(repository, thumbs)
where T : class, IResource, IThumbnails, IQuery where T : class, IResource, IThumbnails, IQuery
@ -53,7 +60,7 @@ public abstract class TranscoderApi<T>(IRepository<T> repository, IThumbnailsMan
} }
) )
.Build(); .Build();
return this.HttpProxyAsync($"http://transcoder:7666{route}", proxyOptions); return this.HttpProxyAsync($"{Transcoder.TranscoderUrl}{route}", proxyOptions);
} }
protected abstract Task<(string path, string route)> GetPath(Identifier identifier); protected abstract Task<(string path, string route)> GetPath(Identifier identifier);

View File

@ -58,7 +58,7 @@ public class ProxyApi(ILibraryManager library) : Controller
} }
) )
.Build(); .Build();
return this.HttpProxyAsync($"http://transcoder:7666/{route}", proxyOptions); return this.HttpProxyAsync($"{Transcoder.TranscoderUrl}{route}", proxyOptions);
} }
/// <summary> /// <summary>

View File

@ -16,6 +16,8 @@ services:
back: back:
build: ./back build: ./back
restart: on-failure restart: on-failure
environment:
- TRANSCODER_URL=${TRANSCODER_URL:-http://transcoder:7666}
env_file: env_file:
- ./.env - ./.env
depends_on: depends_on:

View File

@ -26,6 +26,8 @@ services:
ports: ports:
- "5000:5000" - "5000:5000"
restart: on-failure restart: on-failure
environment:
- TRANSCODER_URL=${TRANSCODER_URL:-http://transcoder:7666}
env_file: env_file:
- ./.env - ./.env
depends_on: depends_on:

View File

@ -17,6 +17,8 @@ services:
image: zoriya/kyoo_back:latest image: zoriya/kyoo_back:latest
restart: unless-stopped restart: unless-stopped
cpus: 1.5 cpus: 1.5
environment:
- TRANSCODER_URL=${TRANSCODER_URL:-http://transcoder:7666}
env_file: env_file:
- ./.env - ./.env
depends_on: depends_on: