Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
leximpact-dotations-back
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Simulateur dotations aux communes
leximpact-dotations-back
Commits
488f7b43
Commit
488f7b43
authored
1 month ago
by
Benoît Courty
Browse files
Options
Downloads
Plain Diff
Merge branch 'deploy-prod' into 'main'
Ajoute le job de CI deploy-prod See merge request
!19
parents
a13c33a3
fbb431da
No related branches found
No related tags found
1 merge request
!19
Ajoute le job de CI deploy-prod
Pipeline
#21512
passed
1 month ago
Stage: install
Stage: test
Stage: build
Stage: deploy
Changes
6
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
.env.example
+1
-1
1 addition, 1 deletion
.env.example
.gitignore
+1
-1
1 addition, 1 deletion
.gitignore
.gitlab-ci.yml
+36
-0
36 additions, 0 deletions
.gitlab-ci.yml
CHANGELOG.md
+4
-0
4 additions, 0 deletions
CHANGELOG.md
README.md
+11
-1
11 additions, 1 deletion
README.md
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
with
54 additions
and
4 deletions
.env
→
.env
.example
+
1
−
1
View file @
488f7b43
...
...
@@ -4,7 +4,7 @@
# possible values: https://docs.python.org/3/library/logging.html#logging-levels
LOGGING_LEVEL=INFO
ORIGINS=[
https://leximpact.an.fr,
http://localhost:5173, http://
localhost:8000, http://localhost
]
ORIGINS=[http://localhost:5173, http://
127.0.0.1:5173, http://dotations.leximpact.an.fr
]
DATA_DIRECTORY="./data"
...
...
This diff is collapsed.
Click to expand it.
.gitignore
+
1
−
1
View file @
488f7b43
This diff is collapsed.
Click to expand it.
.gitlab-ci.yml
+
36
−
0
View file @
488f7b43
...
...
@@ -22,6 +22,8 @@ cache:
# run script before each job's script
before_script
:
# Initialise le .env
-
cp .env.example .env
# install poetry (and collapse section)
-
echo -e "\e[0Ksection_start:`date +%s`:poetry_install_section[collapsed=true]\r\e[0KInstalling poetry..."
-
pip download --dest=${PIP_DOWNLOAD_DIR} poetry
# STEP 1
...
...
@@ -147,3 +149,37 @@ deploy-integ:
# defined in: https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-back/-/environments
name
:
integration
when
:
manual
deploy-prod
:
# SSH_PRIVATE_KEY and PRODUCTION_IP defined in:
# https://git.leximpact.dev/groups/leximpact/simulateur-dotations-communes/-/settings/ci_cd
# PRODUCTION_HOST_DOMAIN_NAME defined in:
# https://git.leximpact.dev/groups/leximpact/-/settings/ci_cd
stage
:
deploy
before_script
:
# install git to have ssh-agent and ssh-add
-
apt update && apt install -y git curl
-
eval $(ssh-agent -s)
-
ssh-add <(echo "$SSH_PRIVATE_KEY")
# check that we are in a container (inside Proxmox LXC container) before bypassing StrictHostKeyChecking
-
'
[[
-f
/.dockerenv
]]
&&
mkdir
-p
~/.ssh
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\tLogLevel
quiet\n"
>
~/.ssh/config'
script
:
# remove previous wheel on integration server and execute the new wheel
-
ssh -J gitlabci@$PRODUCTION_HOST_DOMAIN_NAME leximpact@$PRODUCTION_IP "cd $CI_PROJECT_NAME && rm -v dist/* && exit"
-
scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" -r dist/ leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/
# add the current .env configuration to the container (overwrite it if it already exists)
-
scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" .env leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/.env
# add the current CSV data files to the container (overwrite them if they already exist)
-
scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" data/*csv leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/data/
# get launch_api.py and deploy.sh on container (on SSH port 22)
-
ssh -J gitlabci@$PRODUCTION_HOST_DOMAIN_NAME leximpact@$PRODUCTION_IP "mkdir -p $CI_PROJECT_NAME/.gitlab/ci/ && exit"
-
scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" .gitlab/ci/launch_api.py leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/.gitlab/ci/launch_api.py
-
scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" .gitlab/ci/deploy.sh leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/.gitlab/ci/deploy.sh
# use a ssh relay to connect to the host containing the runner allowed to access the artifacts (wheel)
-
ssh -J gitlabci@$PRODUCTION_HOST_DOMAIN_NAME leximpact@$PRODUCTION_IP "cd $CI_PROJECT_NAME && bash .gitlab/ci/deploy.sh && exit"
environment
:
# defined in: https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-back/-/environments
name
:
production
when
:
manual
only
:
-
main
This diff is collapsed.
Click to expand it.
CHANGELOG.md
+
4
−
0
View file @
488f7b43
# CHANGELOG
### 4.2.2 [!19](https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-back/-/merge_requests/19)
*
Met en place un
`.env.example`
pour la configuration de l'environnement par défaut. Cela permet de ne pas avoir de fichier
`.env`
sur le dépôt.
### 4.2.1 [!20](https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-back/-/merge_requests/20)
*
Correction d'un crash. Optimisation.
...
...
This diff is collapsed.
Click to expand it.
README.md
+
11
−
1
View file @
488f7b43
...
...
@@ -19,13 +19,23 @@ poetry env use python3.11
## Installer `leximpact-dotations-back`
Initialiser la configuration en copiant le modèle de fichier
`.env`
:
```
shell
# dans le répertoire racine du dépôt
# (celui où se trouve ce fichier README.md)
cp
.env.example .env
```
Vérifier que la version de Python associée à Poetry est bien la version attendue :
```
shell
poetry run python
--version
# résultat attendu : Python 3.11.x
```
Pour installer les dépendances de ce dépôt, exécuter la commande suivante dans un terminal Shell :
```
shell
poetry
install
```
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
1
View file @
488f7b43
[tool.poetry]
name
=
"leximpact-dotations-back"
version
=
"4.2.
1
"
version
=
"4.2.
2
"
description
=
"Simulating annual State grants to the French administrative divisions"
authors
=
[
"LexImpact <leximpact@assemblee-nationale.fr>"
]
license
=
"AGPL-3.0-or-later"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment