17 Commits

Author SHA1 Message Date
b96a40e6ed Escaped build args 2024-04-04 21:17:16 -05:00
8dd5a798d9 Changed build_args format
Some checks failed
ci/woodpecker/tag/web_uploadimage Pipeline failed
2024-04-04 21:15:47 -05:00
1ddad9171e Stored entire key-value pair for build args in secrets
Some checks failed
ci/woodpecker/tag/web_uploadimage Pipeline failed
2024-04-04 21:14:21 -05:00
0d5192c156 Changed how build args are passed
Some checks failed
ci/woodpecker/tag/web_uploadimage Pipeline failed
2024-04-04 21:09:53 -05:00
c9689fd114 Removed server_name
All checks were successful
ci/woodpecker/tag/web_uploadimage Pipeline was successful
2024-04-03 23:15:25 -05:00
7ad384fb63 Updated nginx.conf
All checks were successful
ci/woodpecker/tag/web_uploadimage Pipeline was successful
2024-04-03 23:07:35 -05:00
f6578860ab Fixed issue with filtering for yaba-web
All checks were successful
ci/woodpecker/tag/web_uploadimage Pipeline was successful
2024-04-03 21:36:42 -05:00
cf8abed1e2 Added missing latest tag
All checks were successful
ci/woodpecker/tag/api_build Pipeline was successful
ci/woodpecker/tag/api_uploadimage Pipeline was successful
ci/woodpecker/tag/web_uploadimage Pipeline was successful
2024-04-03 21:23:18 -05:00
15f5e43e34 Modified how buildargs are passed
All checks were successful
ci/woodpecker/tag/web_uploadimage Pipeline was successful
2024-04-01 23:24:14 -05:00
6634891de6 Modified how buildargs are passed
Some checks failed
ci/woodpecker/tag/web_uploadimage Pipeline failed
2024-04-01 23:16:12 -05:00
98fc970653 Wrong reference to ref/tags
Some checks failed
ci/woodpecker/tag/api_build Pipeline was successful
ci/woodpecker/tag/api_uploadimage Pipeline was successful
ci/woodpecker/tag/web_uploadimage Pipeline failed
2024-04-01 23:06:27 -05:00
f71211c0b9 Fixed wrong reference to ref, add force remove of file 2024-04-01 22:56:25 -05:00
19fab91db9 Removed skipped clone, fixed wrong syntax for conditional filtering
Some checks failed
ci/woodpecker/tag/web_uploadimage Pipeline failed
ci/woodpecker/tag/api_build Pipeline was successful
ci/woodpecker/tag/api_uploadimage Pipeline failed
2024-04-01 22:52:21 -05:00
8b9a837062 Fixed missing image on versionising prod docker image
Some checks failed
ci/woodpecker/tag/api_build Pipeline failed
ci/woodpecker/tag/api_uploadimage unknown status
ci/woodpecker/tag/web_uploadimage Pipeline failed
2024-04-01 22:42:08 -05:00
be1344e9e5 Add buildargs to web docker build 2024-04-01 22:35:48 -05:00
fc51e2eda9 Modified structure for Woodpecker config 2024-04-01 22:05:10 -05:00
456b8ef75b Created Woodpecker CI/CD deployment
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Created Dockerfile for packing up API and Web projects as Docker image
2024-03-30 22:54:16 -05:00
13 changed files with 21 additions and 93 deletions

1
.gitignore vendored
View File

@ -248,4 +248,5 @@ yarn-debug.log*
yarn-error.log*
.env
Logs/*
docker-compose.yml
*exclude*

View File

@ -25,8 +25,6 @@ steps:
context: ./API
dockerfile: ./API/YABA.API/Dockerfile
tags_file: tags.txt
platforms:
- linux/amd64
username:
from_secret: gitea_yaba_registry_username
password:

View File

@ -18,35 +18,17 @@ steps:
- rm -f tags.txt
- echo ${CI_COMMIT_TAG} | sed -e "s/^WEB-//" >> tags.txt
- echo "latest" >> tags.txt
- name: (YABA.Web) Package and Upload Docker Image (dev)
when:
- ref: refs/tags/WEBDEV-*
- name: (YABA.Web) Package and Upload Docker Image
image: woodpeckerci/plugin-docker-buildx
settings:
repo: gitea.iwanaga.moe/cjtibule/yaba/web
context: ./Web
dockerfile: ./Web/Dockerfile
secrets: [DEV_AUTH0_AUDIENCE, DEV_AUTH0_CLIENT_ID, DEV_AUTH0_DOMAIN, DEV1_API_URL, DEV1_CALLBACK]
tags_file: tags.txt
username:
from_secret: gitea_yaba_registry_username
password:
from_secret: gitea_yaba_registry_password
registry: gitea.iwanaga.moe
build_args:
from_secret: DEV1_BUILDARGS
- name: (YABA.Web) Package and Upload Docker Image (prod)
when:
- ref: refs/tags/WEB-*
image: woodpeckerci/plugin-docker-buildx
settings:
repo: gitea.iwanaga.moe/cjtibule/yaba/web
context: ./Web
dockerfile: ./Web/Dockerfile
tags_file: tags.txt
username:
from_secret: gitea_yaba_registry_username
password:
from_secret: gitea_yaba_registry_password
registry: gitea.iwanaga.moe
build_args:
from_secret: PROD_BUILDARGS
build_args: [${DEV_AUTH0_AUDIENCE}, ${DEV_AUTH0_CLIENT_ID}, ${DEV_AUTH0_DOMAIN}, ${DEV1_API_URL}, ${DEV1_CALLBACK}]

View File

@ -6,16 +6,14 @@ EXPOSE 80
EXPOSE 443
# Set environment variables
ENV ASPNETCORE_Environment=
ENV ASPNETCORE_Environment=Development
ENV ASPNETCORE_Authentication__Auth0__ClientId=
ENV ASPNETCORE_Authentication__Auth0__ClientSecret=
ENV ASPNETCORE_Authentication__Auth0__Domain=
ENV ASPNETCORE_Authentication__Auth0__Identifier=
ENV ASPNETCORE_ConnectionStrings__YABAReadOnlyDbConnectionString=
ENV ASPNETCORE_ConnectionStrings__YABAReadWriteDbConnectionString=
ENV WebClient__Url=
ENV Serilog__WriteTo__1__Args__Uri=
ENV Serilog__WriteTo__1__Args__Labels__1__Value=
ENV ASPNETCORE_WebClient__Url=
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /src

View File

@ -2,7 +2,6 @@
using YABA.API.Extensions;
using YABA.Common.Extensions;
using YABA.Common.Lookups;
using YABA.Common.Utils;
using YABA.Service.Interfaces;
namespace YABA.API.Middlewares
@ -32,7 +31,7 @@ namespace YABA.API.Middlewares
userId = registedUser.Id;
}
httpContext.User.Identities.FirstOrDefault().AddClaim(new Claim(ClaimsLookup.UserId.GetClaimName(EnvironmentUtils.IsDevelopmentEnvironment()), userId.ToString()));
httpContext.User.Identities.FirstOrDefault().AddClaim(new Claim(ClaimsLookup.UserId.GetClaimName(), userId.ToString()));
}
}

View File

@ -97,7 +97,7 @@ var app = builder.Build();
// Run database migrations
using (var scope = app.Services.CreateScope())
{
var yabaDbContext = scope.ServiceProvider.GetRequiredService<YABABaseContext>();
var yabaDbContext = scope.ServiceProvider.GetRequiredService<YABAReadWriteContext>();
yabaDbContext.Database.Migrate();
}

View File

@ -4,13 +4,11 @@ namespace YABA.Common.Attributes
{
public class ClaimNameAttribute : Attribute
{
public string DevClaimName { get; private set; }
public string ProdClaimName { get; private set; }
public string Name { get; private set; }
public ClaimNameAttribute(string devClaimName, string prodClaimName)
public ClaimNameAttribute(string name)
{
this.DevClaimName = devClaimName;
ProdClaimName = prodClaimName;
this.Name = name;
}
}
}

View File

@ -28,9 +28,9 @@ namespace YABA.Common.Extensions
return enumValue.GetAttribute<DisplayAttribute>().Name;
}
public static string GetClaimName(this ClaimsLookup claimLookup, bool isDevelopmentEnvironment)
public static string GetClaimName(this ClaimsLookup claimLookup)
{
return isDevelopmentEnvironment ? claimLookup.GetAttribute<ClaimNameAttribute>().DevClaimName : claimLookup.GetAttribute<ClaimNameAttribute>().ProdClaimName;
return claimLookup.GetAttribute<ClaimNameAttribute>().Name;
}
public static bool IsCrudResultSuccessful(this CrudResultLookup importStatusLookup) => SuccessfulCrudStatuses.Contains(importStatusLookup);

View File

@ -1,8 +1,6 @@
using System;
using System.Security.Claims;
using System.Security.Claims;
using System.Security.Principal;
using YABA.Common.Lookups;
using YABA.Common.Utils;
namespace YABA.Common.Extensions
{
@ -14,7 +12,7 @@ namespace YABA.Common.Extensions
public static string GetCustomClaim(this IIdentity identity, ClaimsLookup claim)
{
var claimsIdentity = identity as ClaimsIdentity;
return claimsIdentity.FindFirst(claim.GetClaimName(EnvironmentUtils.IsDevelopmentEnvironment()))?.Value.ToString();
return claimsIdentity.FindFirst(claim.GetClaimName())?.Value.ToString();
}
}
}

View File

@ -4,19 +4,19 @@ namespace YABA.Common.Lookups
{
public enum ClaimsLookup
{
[ClaimName("https://auth.dev.iwanaga.moe/api/auth_provider_id", "https://auth.iwanaga.moe/api/auth_provider_id")]
[ClaimNameAttribute("https://dev.iwanaga.moe/api/auth_provider_id")]
AuthProviderId = 1,
[ClaimName("https://auth.dev.iwanaga.moe/api/email_address", "https://auth.iwanaga.moe/api/email_address")]
[ClaimNameAttribute("https://dev.iwanaga.moe/api/email_address")]
UserEmail = 2,
[ClaimName("https://auth.dev.iwanaga.moe/api/email_verified", "https://auth.iwanaga.moe/api/email_verified")]
[ClaimNameAttribute("https://dev.iwanaga.moe/api/email_verified")]
IsEmailConfirmed = 3,
[ClaimName("https://auth.dev.iwanaga.moe/api/username", "https://auth.iwanaga.moe/api/username")]
[ClaimNameAttribute("https://dev.iwanaga.moe/api/username")]
Username = 4,
[ClaimName("https://auth.dev.iwanaga.moe/api/id", "https://auth.iwanaga.moe/api/id")]
[ClaimNameAttribute("https://dev.iwanaga.moe/api/id")]
UserId = 5
}
}

View File

@ -1,9 +0,0 @@
using System;
namespace YABA.Common.Utils
{
public static class EnvironmentUtils
{
public static bool IsDevelopmentEnvironment() => Environment.GetEnvironmentVariable("ASPNETCORE_Environment") == "Development";
}
}

View File

@ -2,6 +2,7 @@
"name": "yaba-web",
"version": "0.1.0",
"private": true,
"homepage": ".",
"dependencies": {
"@auth0/auth0-react": "^2.0.0",
"@testing-library/jest-dom": "^5.16.5",

View File

@ -1,38 +0,0 @@
version: "3"
services:
web:
build:
context: ./Web
dockerfile: Dockerfile
args:
REACT_APP_API_BASE_URL: http://localhost:32270/api
REACT_APP_AUTH0_DOMAIN: iwanaga-dev.us.auth0.com
REACT_APP_AUTH0_CLIENT_ID: ${AUTH0_CLIENT_ID}
REACT_APP_AUTH0_CALLBACK_URL: http://localhost:32271/redirect
REACT_APP_AUTH0_AUDIENCE: https://yaba.dev.iwanaga.moe
container_name: yaba_web
restart: unless-stopped
ports:
- 32271:80
depends_on:
- api
api:
build:
context: ./API
dockerfile: YABA.API/Dockerfile
args:
MODE: Debug
container_name: yaba_api
ports:
- 32270:80
environment:
ASPNETCORE_Environment: Development
ASPNETCORE_Authentication__Auth0__ClientId: ${AUTH0_CLIENT_ID}
ASPNETCORE_Authentication__Auth0__ClientSecret: ${AUTH0_CLIENT_SECRET}
ASPNETCORE_Authentication__Auth0__Domain: iwanaga-dev.us.auth0.com
ASPNETCORE_Authentication__Auth0__Identifier: https://yaba.dev.iwanaga.moe
ASPNETCORE_ConnectionStrings__YABAReadOnlyDbConnectionString: ${RO_CONNECTION_STRING}
ASPNETCORE_ConnectionStrings__YABAReadWriteDbConnectionString: ${RW_CONNECTION_STRING}
WebClient__Url: http://localhost:32271
Serilog__WriteTo__1__Args__Uri: https://loki.iwanaga.moe
Serilog__WriteTo__1__Args__Labels__1__Value: localhost