Skip to content

Commit

Permalink
pre-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
dayo.ogundipe committed Oct 20, 2023
1 parent f0657f4 commit 76bea73
Show file tree
Hide file tree
Showing 74 changed files with 4,117 additions and 2,542 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/bin
**/obj
28 changes: 28 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: docker-push

on:
workflow_dispatch:

# push:
# branches:
# - 'main'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: dayosql/reactivities:latest
16 changes: 16 additions & 0 deletions API/Controllers/FallbackController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace API.Controllers
{
[AllowAnonymous]
public class FallbackController: Controller
{
public IActionResult Index()
{
return PhysicalFile(Path.Combine(
Directory.GetCurrentDirectory(),
"wwwroot", "index.html"), "text/HTML");
}
}
}
2 changes: 1 addition & 1 deletion API/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Date = DateOnly.FromDateTime(DateTime.UtcNow.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
Expand Down
43 changes: 39 additions & 4 deletions API/Extensions/ApplicationServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,45 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
services.AddDbContext<DataContext>(opt=>
{
opt.UseSqlite(config.GetConnectionString("DefaultConnection"));
});
services.AddDbContext<DataContext>(options =>
{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

string connStr;

// Depending on if in development or production, use either FlyIO
// connection string, or development connection string from env var.
if (env == "Development")
{
// Use connection string from file.
connStr = config.GetConnectionString("DefaultConnection");
}
else
{
// Use connection string provided at runtime by FlyIO.
var connUrl = Environment.GetEnvironmentVariable("DATABASE_URL");

// Parse connection URL to connection string for Npgsql
connUrl = connUrl.Replace("postgres://", string.Empty);
var pgUserPass = connUrl.Split("@")[0];
var pgHostPortDb = connUrl.Split("@")[1];
var pgHostPort = pgHostPortDb.Split("/")[0];
var pgDb = pgHostPortDb.Split("/")[1];
var pgUser = pgUserPass.Split(":")[0];
var pgPass = pgUserPass.Split(":")[1];
var pgHost = pgHostPort.Split(":")[0];
var pgPort = pgHostPort.Split(":")[1];
var updatedHost = pgHost.Replace("flycast", "internal");

connStr = $"Server={updatedHost};Port={pgPort};User Id={pgUser};Password={pgPass};Database={pgDb};";
}

// Whether the connection string came from the local development configuration file
// or from the environment variable from FlyIO, use it to set up your DbContext.
options.UseNpgsql(connStr);
});



services.Configure<CookiePolicyOptions>(options =>
{
Expand Down
4 changes: 3 additions & 1 deletion API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
app.UseAuthentication();
app.UseAuthorization();


app.UseDefaultFiles();
app.UseStaticFiles();
app.MapFallbackToController("Index", "Fallback");

app.MapControllers();

Expand Down
2 changes: 1 addition & 1 deletion API/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
},
"ConnectionStrings": {
"DefaultConnection": "Data Source=reactivities.db"
"DefaultConnection": "Server=localhost; Port=5432; User Id=admin; Password=secret; Database=reactivities"
},
"TokenKey":"super secret key"
}
Binary file removed API/reactivities.db
Binary file not shown.
Binary file removed API/reactivities.db-shm
Binary file not shown.
Empty file removed API/reactivities.db-wal
Empty file.
Binary file added API/wwwroot/assets/brand-icons-42e369dc.ttf
Binary file not shown.
1,008 changes: 1,008 additions & 0 deletions API/wwwroot/assets/brand-icons-6519a15b.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/brand-icons-9fafd6c3.woff
Binary file not shown.
Binary file added API/wwwroot/assets/brand-icons-d023c55f.eot
Binary file not shown.
Binary file added API/wwwroot/assets/brand-icons-e7d4d534.woff2
Binary file not shown.
Binary file added API/wwwroot/assets/categoryImages/culture.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/categoryImages/drinks.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/categoryImages/film.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/categoryImages/food.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/categoryImages/music.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/categoryImages/travel.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/flags-94d5c7f1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,518 changes: 1,518 additions & 0 deletions API/wwwroot/assets/icons-282a64fb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/icons-434466b5.woff2
Binary file not shown.
Binary file added API/wwwroot/assets/icons-8b4e1b84.eot
Binary file not shown.
Binary file added API/wwwroot/assets/icons-95b6a484.woff
Binary file not shown.
Binary file added API/wwwroot/assets/icons-cb7f81f5.ttf
Binary file not shown.
120 changes: 120 additions & 0 deletions API/wwwroot/assets/index-1e8ecb79.js

Large diffs are not rendered by default.

354 changes: 354 additions & 0 deletions API/wwwroot/assets/index-bc0962bb.css

Large diffs are not rendered by default.

Binary file added API/wwwroot/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/outline-icons-4537fa06.eot
Binary file not shown.
Binary file added API/wwwroot/assets/outline-icons-4bc359c2.woff
Binary file not shown.
Binary file not shown.
Binary file added API/wwwroot/assets/outline-icons-67172172.ttf
Binary file not shown.
366 changes: 366 additions & 0 deletions API/wwwroot/assets/outline-icons-ae8fd02a.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/wwwroot/assets/user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions API/wwwroot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Reactivities</title>
<script type="module" crossorigin src="/assets/index-1e8ecb79.js"></script>
<link rel="stylesheet" href="/assets/index-bc0962bb.css">
</head>
<body>
<div id="root"></div>

</body>
</html>
1 change: 1 addition & 0 deletions API/wwwroot/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Application/Profiles/ListActivities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public async Task<Result<List<UserActivityDto>>> Handle(Query request, Cancellat

if(request.Predicate =="past")
{
query = query.Where(x=>x.Date <= DateTime.Now);
query = query.Where(x=>x.Date <= DateTime.UtcNow);
}

else if(request.Predicate =="hosting")
{
query = query.Where(a=>a.HostUsername ==_userAccessor.GetUsername());
}
else {
query = query.Where(x=>x.Date>= DateTime.Now);
query = query.Where(x=>x.Date>= DateTime.UtcNow);
}

var activities = await query.ToListAsync();
Expand Down
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 as build-env
WORKDIR /app
EXPOSE 8080


# copy .csproj and restore as distinct layers
COPY "Reactivities.sln" "Reactivities.sln"
COPY "API/API.csproj" "API/API.csproj"
COPY "Application/Application.csproj" "Application/Application.csproj"
COPY "Persistence/Persistence.csproj" "Persistence/Persistence.csproj"
COPY "Domain/Domain.csproj" "Domain/Domain.csproj"
COPY "Infrastructure/Infrastructure.csproj" "Infrastructure/Infrastructure.csproj"

RUN dotnet restore "Reactivities.sln"

# copy everything else build
COPY . .
WORKDIR /app
RUN dotnet publish -c Release -o out

#build a runtine image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT [ "dotnet", "API.dll" ]
54 changes: 0 additions & 54 deletions Persistence/Migrations/20230910172838_InitalCreate.Designer.cs

This file was deleted.

39 changes: 0 additions & 39 deletions Persistence/Migrations/20230910172838_InitalCreate.cs

This file was deleted.

Loading

0 comments on commit 76bea73

Please sign in to comment.