tests
maxime 1 year ago
parent 5eaa35ba8f
commit d34e196830

@ -54,6 +54,15 @@ builder.Services.AddScoped<ITacticService, DbTacticService>();
var app = builder.Build(); var app = builder.Build();
System.AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
app.Use((context, next) =>
{
var req = context.Request;
Console.WriteLine($"{req.Method}: {req.Path}{req.QueryString}");
return next.Invoke();
});
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {

@ -6,7 +6,7 @@
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning", "Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.Authentication": "Trace" "Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Trace"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*"

@ -33,7 +33,6 @@ public class AppContext : DbContext
} }
var pgsqliteDsn = Environment.GetEnvironmentVariable("PGSQL_DSN"); var pgsqliteDsn = Environment.GetEnvironmentVariable("PGSQL_DSN");
Console.WriteLine(pgsqliteDsn);
if (pgsqliteDsn != null) if (pgsqliteDsn != null)
{ {

@ -19,7 +19,7 @@ steps:
registry: hub.codefirst.iut.uca.fr registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet repo: hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet
tags: tags:
- ${DRONE_BRANCH} - ${DRONE_BRANCH/\//_}
username: username:
from_secret: SECRET_REGISTRY_USERNAME from_secret: SECRET_REGISTRY_USERNAME
password: password:
@ -39,36 +39,36 @@ steps:
- chmod 0600 ~/.ssh - chmod 0600 ~/.ssh
- chmod 0500 ~/.ssh/id_rsa* - chmod 0500 ~/.ssh/id_rsa*
- rsync -avz -e "ssh -p 80 -o 'StrictHostKeyChecking=no'" ci/deploy_staging_server.sh iqball@maxou.dev:/srv/www/iqball/$DRONE_BRANCH - rsync -avz -e "ssh -p 80 -o 'StrictHostKeyChecking=no'" ci/deploy_staging_server.sh iqball@maxou.dev:/srv/www/iqball/$DRONE_BRANCH
- ssh -p 80 -o 'StrictHostKeyChecking=no' iqball@maxou.dev "chmod +x /srv/www/iqball/$DRONE_BRANCH/deploy_staging_server.sh && /srv/www/iqball/$DRONE_BRANCH/deploy_staging_server.sh $DRONE_BRANCH" - ssh -p 80 -o 'StrictHostKeyChecking=no' iqball@maxou.dev "chmod +x /srv/www/iqball/$DRONE_BRANCH/deploy_staging_server.sh && /srv/www/iqball/$DRONE_BRANCH/deploy_staging_server.sh $(echo $DRONE_BRANCH | tr / _) $DRONE_COMMIT_SHA"
# Deploy the production database and server on codefirst # Deploy the production database and server on codefirst
- image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest # - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
name: "Instantiate dotnet api docker image on codefirst" # name: "Instantiate dotnet api docker image on codefirst"
depends_on: # depends_on:
- "build and push docker image" # - "build and push docker image"
environment: # environment:
IMAGENAME: hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:master # IMAGENAME: hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:master
CONTAINERNAME: iqball_production_dotnet_webserver # CONTAINERNAME: iqball_production_dotnet_webserver
OVERWRITE: true # OVERWRITE: true
COMMAND: create # COMMAND: create
#
CODEFIRST_CLIENTDRONE_ENV_PGSQL_DSN: # CODEFIRST_CLIENTDRONE_ENV_PGSQL_DSN:
from_secret: POSTGRES_DSN # from_secret: POSTGRES_DSN
ADMINS: maximebatista # ADMINS: maximebatista
#
- image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest # - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
name: "Instantiate pgsql database docker image on codefirst" # name: "Instantiate pgsql database docker image on codefirst"
depends_on: # depends_on:
- "build and push docker image" # - "build and push docker image"
environment: # environment:
IMAGENAME: postgres # IMAGENAME: postgres
CONTAINERNAME: iqball_production_database # CONTAINERNAME: iqball_production_database
COMMAND: create # COMMAND: create
#
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_PASSWORD: # CODEFIRST_CLIENTDRONE_ENV_POSTGRES_PASSWORD:
from_secret: POSTGRES_PASSWORD # from_secret: POSTGRES_PASSWORD
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER: # CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER:
from_secret: POSTGRES_USER # from_secret: POSTGRES_USER
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB: # CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB:
from_secret: POSTGRES_DB # from_secret: POSTGRES_DB
ADMINS: maximebatista # ADMINS: maximebatista

@ -10,6 +10,5 @@ ENV PATH="$PATH:/root/.dotnet/tools"
ADD --chmod=755 db-init.sh ./ ADD --chmod=755 db-init.sh ./
ENTRYPOINT ./db-init.sh $BRANCH $COMMIT_SHA
ENTRYPOINT ./db-init.sh $BRANCH

@ -1,13 +1,22 @@
set -xeu set -xeu
BRANCH=$1
COMMIT_SHA=$2
git clone https://codefirst.iut.uca.fr/git/IQBall/Dotnet-WebAPI git clone https://codefirst.iut.uca.fr/git/IQBall/Dotnet-WebAPI
cd Dotnet-WebAPI cd Dotnet-WebAPI
git switch $1 git switch $BRANCH
#TODO remove migrations that are bound to commits that are no longer in the branch (which could occur via a rebase)
(cd AppContext && rm -rf Migrations && dotnet ef migrations add iqball-postgres-db-mig) cd AppContext
(cd API && dotnet ef database update --project ../AppContext) rm -rf Migrations # remove migrations from git
ln -s /migrations Migrations # bind auto branch migrations to the project
# apply migrations
dotnet ef migrations add "auto-migration-$COMMIT_SHA"
# update database
dotnet ef database update

@ -2,10 +2,14 @@
set -exu set -exu
API_CONTAINER_NAME="iqball-api-dotnet-$1" BRANCH=$1
DB_CONTAINER_NAME="iqball-db-$1" COMMIT_SHA=$2
API_CONTAINER_NAME="iqball-api-dotnet-$BRANCH"
DB_CONTAINER_NAME="iqball-db-$BRANCH"
(docker stop "$API_CONTAINER_NAME" && docker rm "$API_CONTAINER_NAME") || true (docker stop "$API_CONTAINER_NAME" && docker rm "$API_CONTAINER_NAME") || true
docker volume create "iqball-migrations-$BRANCH" || true
docker run -d \ docker run -d \
--name "$DB_CONTAINER_NAME" \ --name "$DB_CONTAINER_NAME" \
@ -19,12 +23,14 @@ docker run -d \
# apply migrations on database # apply migrations on database
docker run --rm -t \ docker run --rm -t \
--env PGSQL_DSN="Server=$DB_CONTAINER_NAME;Username=iqball;Password=1234;Database=iqball" \ --env PGSQL_DSN="Server=$DB_CONTAINER_NAME;Username=iqball;Password=1234;Database=iqball" \
--env BRANCH="$1" \ --env BRANCH="$BRANCH" \
--env COMMIT_SHA="$COMMIT_SHA" \
--mount source="iqball-migrations-$BRANCH",target=/migrations \
--network iqball_net \ --network iqball_net \
iqball-db-init:latest iqball-db-init:latest
docker pull "hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:$1" docker pull "hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:$BRANCH"
# run the API # run the API
docker run -d \ docker run -d \
@ -32,7 +38,7 @@ docker run -d \
--restart=always \ --restart=always \
--network iqball_net \ --network iqball_net \
--env PGSQL_DSN="Server=$DB_CONTAINER_NAME;Username=iqball;Password=1234;Database=iqball" \ --env PGSQL_DSN="Server=$DB_CONTAINER_NAME;Username=iqball;Password=1234;Database=iqball" \
"hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:$1" "hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:$BRANCH"

Loading…
Cancel
Save