WIP: build production images
Some checks failed
Build Docker Images / build-and-push (push) Failing after 1m30s
Some checks failed
Build Docker Images / build-and-push (push) Failing after 1m30s
This commit is contained in:
45
BimAI.API/Dockerfile
Normal file
45
BimAI.API/Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
||||
# Stage 1: Build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Copy solution and all project files for restore
|
||||
COPY BimAI.sln ./
|
||||
COPY BimAI.API/BimAI.API.csproj BimAI.API/
|
||||
COPY BimAI.Domain/BimAI.Domain.csproj BimAI.Domain/
|
||||
COPY BimAI.Application/BimAI.Application.csproj BimAI.Application/
|
||||
COPY BimAI.Infrastructure/BimAI.Infrastructure.csproj BimAI.Infrastructure/
|
||||
|
||||
# Restore dependencies
|
||||
RUN dotnet restore BimAI.API/BimAI.API.csproj
|
||||
|
||||
# Copy all source code
|
||||
COPY . .
|
||||
|
||||
# Build and publish
|
||||
WORKDIR /src/BimAI.API
|
||||
RUN dotnet publish -c Release -o /app/publish --no-restore
|
||||
|
||||
# Stage 2: Runtime
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
# Set timezone
|
||||
ENV TZ=Europe/Warsaw
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# Copy published files
|
||||
COPY --from=build /app/publish .
|
||||
|
||||
# Set environment variables
|
||||
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||
ENV ASPNETCORE_URLS=http://0.0.0.0:7142
|
||||
|
||||
# Expose port
|
||||
EXPOSE 7142
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:7142/health || exit 1
|
||||
|
||||
# Run the application
|
||||
ENTRYPOINT ["dotnet", "BimAI.API.dll"]
|
||||
@@ -100,13 +100,19 @@ app.UseAuthorization();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
|
||||
app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow }))
|
||||
.AllowAnonymous();
|
||||
|
||||
RecurringJob.AddOrUpdate<ProductSyncJob>(
|
||||
"product-sync",
|
||||
job => job.ExecuteAsync(),
|
||||
Cron.Daily(2, 0), // Every day at 2:00 AM
|
||||
new RecurringJobOptions
|
||||
{
|
||||
TimeZone = TimeZoneInfo.Local
|
||||
TimeZone = TimeZoneInfo.Local,
|
||||
MisfireHandling = app.Environment.IsDevelopment()
|
||||
? MisfireHandlingMode.Relaxed
|
||||
: MisfireHandlingMode.Strict
|
||||
});
|
||||
|
||||
app.Run();
|
||||
Binary file not shown.
38
BimAI.API/appsettings.Production.json
Normal file
38
BimAI.API/appsettings.Production.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "#{db-connection-string}#",
|
||||
"HangfireConnection": "#{hangfire-connection-string}#"
|
||||
},
|
||||
"E5_CRM": {
|
||||
"ApiKey": "#{e5-crm-api-key}#"
|
||||
},
|
||||
"GoogleAuth": {
|
||||
"ClientId": "#{google-auth-client-id}#"
|
||||
},
|
||||
"JwtSettings": {
|
||||
"SecretKey": "#{jwt-secret-key}#",
|
||||
"Issuer": "#{jwt-issuer}#",
|
||||
"Audience": "#{jwt-audience}#",
|
||||
"ExpiryDays": 7
|
||||
},
|
||||
"Hangfire": {
|
||||
"ServerName": "#{hangfire-server-name}#",
|
||||
"WorkerCount": 5,
|
||||
"DashboardPath": "/hangfire"
|
||||
},
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://0.0.0.0:7142"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user