tests
Maxime BATISTA 9 months ago
parent 5eaa35ba8f
commit d34e196830

@ -54,6 +54,15 @@ builder.Services.AddScoped<ITacticService, DbTacticService>();
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.
if (app.Environment.IsDevelopment())
{

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

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

@ -19,7 +19,7 @@ steps:
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet
tags:
- ${DRONE_BRANCH}
- ${DRONE_BRANCH/\//_}
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
@ -39,36 +39,36 @@ steps:
- chmod 0600 ~/.ssh
- 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
- 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
- image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
name: "Instantiate dotnet api docker image on codefirst"
depends_on:
- "build and push docker image"
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:master
CONTAINERNAME: iqball_production_dotnet_webserver
OVERWRITE: true
COMMAND: create
CODEFIRST_CLIENTDRONE_ENV_PGSQL_DSN:
from_secret: POSTGRES_DSN
ADMINS: maximebatista
- image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
name: "Instantiate pgsql database docker image on codefirst"
depends_on:
- "build and push docker image"
environment:
IMAGENAME: postgres
CONTAINERNAME: iqball_production_database
COMMAND: create
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_PASSWORD:
from_secret: POSTGRES_PASSWORD
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER:
from_secret: POSTGRES_USER
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB:
from_secret: POSTGRES_DB
ADMINS: maximebatista
# Deploy the production database and server on codefirst
# - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
# name: "Instantiate dotnet api docker image on codefirst"
# depends_on:
# - "build and push docker image"
# environment:
# IMAGENAME: hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:master
# CONTAINERNAME: iqball_production_dotnet_webserver
# OVERWRITE: true
# COMMAND: create
#
# CODEFIRST_CLIENTDRONE_ENV_PGSQL_DSN:
# from_secret: POSTGRES_DSN
# ADMINS: maximebatista
#
# - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
# name: "Instantiate pgsql database docker image on codefirst"
# depends_on:
# - "build and push docker image"
# environment:
# IMAGENAME: postgres
# CONTAINERNAME: iqball_production_database
# COMMAND: create
#
# CODEFIRST_CLIENTDRONE_ENV_POSTGRES_PASSWORD:
# from_secret: POSTGRES_PASSWORD
# CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER:
# from_secret: POSTGRES_USER
# CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB:
# from_secret: POSTGRES_DB
# ADMINS: maximebatista

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

@ -1,13 +1,22 @@
set -xeu
BRANCH=$1
COMMIT_SHA=$2
git clone https://codefirst.iut.uca.fr/git/IQBall/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 API && dotnet ef database update --project ../AppContext)
cd 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
API_CONTAINER_NAME="iqball-api-dotnet-$1"
DB_CONTAINER_NAME="iqball-db-$1"
BRANCH=$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 volume create "iqball-migrations-$BRANCH" || true
docker run -d \
--name "$DB_CONTAINER_NAME" \
@ -19,12 +23,14 @@ docker run -d \
# apply migrations on database
docker run --rm -t \
--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 \
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
docker run -d \
@ -32,7 +38,7 @@ docker run -d \
--restart=always \
--network iqball_net \
--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