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.Id,
entity.ParentId, entity.ParentId,
steps.Where(s =>s.TacticId == entity.TacticId && s.ParentId == entity.Id) steps.Where(s =>s.TacticId == entity.TacticId && s.ParentId == entity.Id)
.AsEnumerable() .ToList()
.Select(e => e.ToModel(steps)), .Select(e => e.ToModel(steps)),
entity.JsonContent entity.JsonContent
); );

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

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