fix concurrent PGSQL error
continuous-integration/drone/push Build is passing Details

shared-tactic
Maxime BATISTA 8 months ago
parent ea827253e4
commit 89880432c1

@ -22,7 +22,7 @@ public static class EntitiesToModels
entity.Id,
entity.ParentId,
steps.Where(s =>s.TacticId == entity.TacticId && s.ParentId == entity.Id)
.AsEnumerable()
.ToList()
.Select(e => e.ToModel(steps)),
entity.JsonContent
);

@ -35,7 +35,7 @@ steps:
from_secret: SECRET_REGISTRY_PASSWORD
# deploy staging database and server on codefirst
- image: eeacms/rsync:latest
- image: ubuntu:latest
name: "Instantiate docker images on staging server"
depends_on:
- "build and push docker image"
@ -43,13 +43,10 @@ steps:
PRIVATE_KEY:
from_secret: PRIVATE_KEY
commands:
- mkdir -p ~/.ssh
- echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
- 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 $(echo $DRONE_BRANCH | tr / _) $DRONE_COMMIT_SHA"
- chmod +x ci/deploy_staging_server_step.sh
- ci/deploy_staging_server_step.sh
# 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"

@ -3,13 +3,14 @@
set -exu
BRANCH=$1
BRANCH_ESCAPED=$(echo $BRANCH | tr / _)
COMMIT_SHA=$2
API_CONTAINER_NAME="iqball-api-dotnet-$BRANCH"
DB_CONTAINER_NAME="iqball-db-$BRANCH"
API_CONTAINER_NAME="iqball-api-dotnet-$BRANCH_ESCAPED"
DB_CONTAINER_NAME="iqball-db-$BRANCH_ESCAPED"
(docker stop "$API_CONTAINER_NAME" && docker rm "$API_CONTAINER_NAME") || true
docker volume create "iqball-migrations-$BRANCH" || true
docker volume create "iqball-migrations-$BRANCH_ESCAPED" || true
docker run -d \
--name "$DB_CONTAINER_NAME" \
@ -25,12 +26,12 @@ docker run --rm -t \
--env PGSQL_DSN="Server=$DB_CONTAINER_NAME;Username=iqball;Password=1234;Database=iqball" \
--env BRANCH="$BRANCH" \
--env COMMIT_SHA="$COMMIT_SHA" \
--mount source="iqball-migrations-$BRANCH",target=/migrations \
--mount source="iqball-migrations-$BRANCH_ESCAPED",target=/migrations \
--network iqball_net \
iqball-db-init:latest
docker pull "hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:$BRANCH"
docker pull "hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:$BRANCH_ESCAPED"
# run the API
docker run -d \
@ -38,7 +39,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:$BRANCH"
"hub.codefirst.iut.uca.fr/maxime.batista/iqball-api-dotnet:$BRANCH_ESCAPED"

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -exu
apt update && apt install rsync openssh-client -y
mkdir -p ~/.ssh
echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 0600 ~/.ssh
chmod 0500 ~/.ssh/id_rsa*
ssh -p 80 -o 'StrictHostKeyChecking=no' iqball@maxou.dev mkdir -p /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 $DRONE_COMMIT_SHA"
Loading…
Cancel
Save