Spaces:
Sleeping
Sleeping
Yuyuqt commited on
Commit ·
e36e2eb
1
Parent(s): ed77e1a
Deploying to Hugging Face
Browse files- .dockerignore +9 -0
- Backend/Program.cs +15 -3
- Dockerfile +29 -0
.dockerignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
**/.dockerignore
|
| 2 |
+
**/.git
|
| 3 |
+
**/.gitignore
|
| 4 |
+
**/.vs
|
| 5 |
+
**/bin
|
| 6 |
+
**/obj
|
| 7 |
+
**/*.user
|
| 8 |
+
**/node_modules
|
| 9 |
+
**/wwwroot
|
Backend/Program.cs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
using System.Text;
|
| 2 |
using DbConnect.Data;
|
| 3 |
using DbConnect.Entities;
|
|
@@ -21,10 +22,21 @@ AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
|
| 21 |
var builder = WebApplication.CreateBuilder(args);
|
| 22 |
|
| 23 |
// Firebase Admin SDK Initialization
|
| 24 |
-
|
|
|
|
| 25 |
{
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
builder.Services.AddCors(options =>
|
| 30 |
{
|
|
|
|
| 1 |
+
using System.IO;
|
| 2 |
using System.Text;
|
| 3 |
using DbConnect.Data;
|
| 4 |
using DbConnect.Entities;
|
|
|
|
| 22 |
var builder = WebApplication.CreateBuilder(args);
|
| 23 |
|
| 24 |
// Firebase Admin SDK Initialization
|
| 25 |
+
var firebaseConfig = Environment.GetEnvironmentVariable("FIREBASE_CONFIG");
|
| 26 |
+
if (!string.IsNullOrEmpty(firebaseConfig))
|
| 27 |
{
|
| 28 |
+
FirebaseApp.Create(new AppOptions()
|
| 29 |
+
{
|
| 30 |
+
Credential = GoogleCredential.FromJson(firebaseConfig)
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
else if (File.Exists("LibraryFirebase.json"))
|
| 34 |
+
{
|
| 35 |
+
FirebaseApp.Create(new AppOptions()
|
| 36 |
+
{
|
| 37 |
+
Credential = GoogleCredential.FromFile("LibraryFirebase.json")
|
| 38 |
+
});
|
| 39 |
+
}
|
| 40 |
|
| 41 |
builder.Services.AddCors(options =>
|
| 42 |
{
|
Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Build stage
|
| 2 |
+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
| 3 |
+
WORKDIR /src
|
| 4 |
+
|
| 5 |
+
# Copy project files for restoring dependencies
|
| 6 |
+
COPY ["Backend/Backend.csproj", "Backend/"]
|
| 7 |
+
COPY ["DbConnect/DbConnect.csproj", "DbConnect/"]
|
| 8 |
+
COPY ["LibraryManagement.Shared/LibraryManagement.Shared.csproj", "LibraryManagement.Shared/"]
|
| 9 |
+
|
| 10 |
+
# Restore dependencies
|
| 11 |
+
RUN dotnet restore "Backend/Backend.csproj"
|
| 12 |
+
|
| 13 |
+
# Copy everything else and build
|
| 14 |
+
COPY . .
|
| 15 |
+
WORKDIR "/src/Backend"
|
| 16 |
+
RUN dotnet publish "Backend.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
| 17 |
+
|
| 18 |
+
# Final stage
|
| 19 |
+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
|
| 20 |
+
WORKDIR /app
|
| 21 |
+
COPY --from=build /app/publish .
|
| 22 |
+
|
| 23 |
+
# --- HUGGING FACE SPECIFIC CONFIG ---
|
| 24 |
+
# Hugging Face requires port 7860
|
| 25 |
+
EXPOSE 7860
|
| 26 |
+
ENV ASPNETCORE_URLS=http://+:7860
|
| 27 |
+
# ------------------------------------
|
| 28 |
+
|
| 29 |
+
ENTRYPOINT ["dotnet", "Backend.dll"]
|