Fix docker build

This commit is contained in:
kurt-mcrae
2024-11-23 23:01:04 +11:00
parent 8b3bf99fcf
commit 99506da118
3 changed files with 42 additions and 10 deletions
@@ -54,10 +54,10 @@ public static class ServiceCollectionExtensions
await context.HttpContext.Response.WriteAsync("Rate limit exceeded, please try again in one minute",
token);
})
.AddHangfireServer()
.AddHangfire(config =>
config.UsePostgreSqlStorage(c =>
c.UseNpgsqlConnection(connectionString)));
c.UseNpgsqlConnection(connectionString)))
.AddHangfireServer();
}
public static void SetupConfiguration(this IServiceCollection services, IConfiguration configuration)
+24 -5
View File
@@ -5,21 +5,40 @@ namespace backend.Services.Init;
public class HangfireInitialiser
{
private readonly ILogger<HangfireInitialiser> _logger;
private readonly IRecurringJobManager _recurringJobManager;
public HangfireInitialiser(ILogger<HangfireInitialiser> logger)
public HangfireInitialiser(ILogger<HangfireInitialiser> logger, IRecurringJobManager recurringJobManager)
{
_logger = logger;
_recurringJobManager = recurringJobManager;
}
public void RegisterFuelApiRefreshJobs()
{
_logger.LogInformation("Registering recurring jobs");
//four-hourly refresh for reference data = 124/month max.
RecurringJob.AddOrUpdate<INswFuelApiService>("refresh_lovs", x => x.GetLovsAsync(), "0 */4 * * *");
_recurringJobManager.AddOrUpdate<INswFuelApiService>(
"refresh_lovs",
x => x.GetLovsAsync(),
"0 */4 * * *");
//twenty minute refresh for prices = 2,232/month max.
RecurringJob.AddOrUpdate<INswFuelApiService>("refresh_prices", x => x.GetCurrentPricesAsync(), "*/20 * * * *");
_recurringJobManager.AddOrUpdate<INswFuelApiService>(
"refresh_prices",
x => x.GetCurrentPricesAsync(),
"*/20 * * * *");
//daily refresh for suburb boundaries at midnight - do this in Sydney time (safe to assume the app will be run in NSW)
RecurringJob.AddOrUpdate<ISuburbBoundariesService>("fetch_suburb_boundaries", x => x.FetchFeatures(),
_recurringJobManager.AddOrUpdate<ISuburbBoundariesService>(
"fetch_suburb_boundaries",
x => x.FetchFeatures(),
"0 0 * * *",
new RecurringJobOptions { TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Australia/Sydney") });
new RecurringJobOptions
{
TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Australia/Sydney")
});
_logger.LogInformation("Recurring jobs for registered successfully");
}
}
+16 -3
View File
@@ -1,4 +1,10 @@
services:
version: '3.8'
networks:
app-network:
driver: bridge
services:
backend-prod:
image: backend-prod
build:
@@ -6,7 +12,12 @@
dockerfile: Dockerfile
restart: unless-stopped
container_name: backend-prod
networks:
- app-network
ports:
#update to suit your needs (3000:5000 would expose the API as port 3000 on the host machine, for example)
- "5000:5000"
timescaledb-prod:
image: timescale/timescaledb-ha:pg16
ports:
@@ -14,4 +25,6 @@
environment:
- POSTGRES_PASSWORD=password
restart: unless-stopped
container_name: timescaledb-prod
container_name: timescaledb-prod
networks:
- app-network