Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'LBB-23/upgrade_flask' into 'master'
Browse files Browse the repository at this point in the history
♻️ upgrade flask

See merge request lbb/lbb!632
  • Loading branch information
lmarvaud committed Sep 26, 2022
2 parents 7b3bc0e + c5a21bc commit 828e148
Show file tree
Hide file tree
Showing 74 changed files with 2,727 additions and 1,698 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/lbb-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ name: LBB CI

on:
push:
branches: [ "master"]
branches: [ "*"]
pull_request:
branches: [ "master"]
workflow_dispatch:
inputs:
git-ref:
description: Git Ref (Optional)
required: false

jobs:
tests:
Expand All @@ -15,7 +20,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.6.8]
python-version: [3.10.4]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ labonneboite/web/static/gen/

# virtualenv
venv/
logs/
__pycache__
40 changes: 0 additions & 40 deletions Dockerfile

This file was deleted.

32 changes: 16 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,53 +215,53 @@ start-locust-against-localhost:

# Tests
# -----
NOSETESTS_OPTS ?=
NOSETESTS = nosetests -s $(NOSETESTS_OPTS)
PYTEST_OPTS ?= -vx
PYTEST = pytest $(PYTEST_OPTS)
TESTS = labonneboite/tests/app/ \
labonneboite/tests/web/ \
labonneboite/tests/scripts/

test-unit: clean-pyc rebuild-data-test
LBB_ENV=test $(NOSETESTS) ${TESTS}
LBB_ENV=test $(PYTEST) ${TESTS}

test: test-unit test-selenium test-integration

check-all: test-all

test-app:
LBB_ENV=test $(NOSETESTS) labonneboite/tests/app
LBB_ENV=test $(PYTEST) labonneboite/tests/app

test-api:
LBB_ENV=test $(NOSETESTS) labonneboite/tests/web/api
LBB_ENV=test $(PYTEST) labonneboite/tests/web/api

test-front:
LBB_ENV=test $(NOSETESTS) labonneboite/tests/web/front
LBB_ENV=test $(PYTEST) labonneboite/tests/web/front

test-web: test-api test-front test-web-integration

test-scripts:
LBB_ENV=test $(NOSETESTS) labonneboite/tests/scripts
LBB_ENV=test $(PYTEST) labonneboite/tests/scripts

test-integration: clear-data-test database-test populate-data-test
LBB_ENV=test $(NOSETESTS) labonneboite/tests/integration
LBB_ENV=test $(PYTEST) labonneboite/tests/integration

test-selenium: clear-data-test database-test populate-data-test-selenium
LBB_ENV=test SELENIUM_IS_SETUP=1 $(NOSETESTS) labonneboite/tests/selenium
LBB_ENV=test SELENIUM_IS_SETUP=1 $(PYTEST) labonneboite/tests/selenium

# Convenient reminder about how to run a specific test manually.
test-custom:
@echo "To run a specific test, run for example:"
@echo
@echo " $$ LBB_ENV=test nosetests -s labonneboite/tests/web/api/test_api.py"
@echo " $$ LBB_ENV=test pytest -s labonneboite/tests/web/api/test_api.py"
@echo
@echo "and you can even run a specific method, here are several examples:"
@echo
@echo " $$ LBB_ENV=test nosetests -s labonneboite/tests/web/api/test_api.py:ApiCompanyListTest.test_query_returns_scores_adjusted_to_rome_code_context"
@echo " $$ LBB_ENV=test nosetests -s labonneboite/tests/web/api/test_api.py:ApiOffersOfficesListTest"
@echo " $$ LBB_ENV=test nosetests -s labonneboite/tests/web/front/test_routes.py"
@echo " $$ LBB_ENV=test nosetests -s labonneboite/tests/app/test_suggest_locations.py"
@echo " $$ LBB_ENV=test nosetests -s labonneboite/tests/scripts/test_create_index.py:DeleteOfficeAdminTest.test_office_admin_add"
@echo " $$ LBB_ENV=test nosetests -s labonneboite/tests/selenium/test_search_selecting_car.py:TestSearchSelectingCar.test_commute_time_is_displayed"
@echo " $$ LBB_ENV=test pytest -s labonneboite/tests/web/api/test_api.py:ApiCompanyListTest.test_query_returns_scores_adjusted_to_rome_code_context"
@echo " $$ LBB_ENV=test pytest -s labonneboite/tests/web/api/test_api.py:ApiOffersOfficesListTest"
@echo " $$ LBB_ENV=test pytest -s labonneboite/tests/web/front/test_routes.py"
@echo " $$ LBB_ENV=test pytest -s labonneboite/tests/app/test_suggest_locations.py"
@echo " $$ LBB_ENV=test pytest -s labonneboite/tests/scripts/test_create_index.py:DeleteOfficeAdminTest.test_office_admin_add"
@echo " $$ LBB_ENV=test pytest -s labonneboite/tests/selenium/test_search_selecting_car.py:TestSearchSelectingCar.test_commute_time_is_displayed"
@echo
@echo "Note that you can set the env var `NOSE_NOCAPTURE=1` to keep logs in the console"

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ La Bonne Boite is a [web site](https://labonneboite.pole-emploi.fr) and an [API]

### Install OS requirements:

- python == 3.6.8
- python == 3.10.4
- docker-compose
- mysql-client
- libmysqlclient-dev
Expand All @@ -108,19 +108,19 @@ On fedora

You will also need to install docker and docker-compose. Follow the instructions related to your particular OS from the [official Docker documentation](https://docs.docker.com/install/).

### Create a virtualenv for Python 3.6
### Create a virtualenv for Python 3.10

For now, La Bonne Boite runs in production under Python 3.6.8. You are going to have to create a virtualenv that runs this specific version of Python.
For now, La Bonne Boite runs in production under Python 3.10.4. You are going to have to create a virtualenv that runs this specific version of Python.

$ wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
$ tar -xvzf Python-3.6.8.tgz
$ cd Python-3.6.8
$ wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tgz
$ tar -xvzf Python-3.10.4.tgz
$ cd Python-3.10.4
$ ./configure --prefix=/usr/local --enable-loadable-sqlite-extensions
$ sudo make altinstall

Create an [isolated Python environment](https://virtualenv.pypa.io/), for example using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/):

$ mkvirtualenv --python=`which python3.6` lbb
$ mkvirtualenv --python=`which python3.10` lbb
$ workon lbb

You might need to add `labonneboite` base directory to the Python path. This has to be run only once. One way to do it using `virtualenvwrapper`:
Expand Down
125 changes: 62 additions & 63 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,53 @@
version: "3"
version: "3.7"

# settings
x-db-env: &dbenv
MYSQL_ROOT_PASSWORD: p@ssword
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: labonneboite
MYSQL_USER: labonneboite
MYSQL_PASSWORD: labonneboite

x-common-env: &cenv
DB_ROOT_PASSWORD: p@ssword
DB_DATABASE: labonneboite
DB_NAME: labonneboite
DB_USER: labonneboite
DB_PASSWORD: labonneboite
DB_PORT: 3306
ES_HOST: elasticsearch:9200
DB_HOST: mysql
OFFICE_TABLE: etablissements
LBB_ENV: development

services:
nginx:

labonneboite:
hostname: labonneboite-backend
restart: always
image: nginx:1.13
build:
context: .
dockerfile: docker/v3.6/Dockerfile
args:
options: --reload
environment:
<<: *cenv
volumes:
- ./nginx/etc/nginx/conf.d:/etc/nginx/conf.d
- ./nginx/var/log/labonneboite:/var/log/nginx/labonneboite
ports:
- ${HTTP_PORT:-8000}:8000
- ./logs:/app/labonneboite/logs
- ./labonneboite:/app/labonneboite
depends_on:
- labonneboite
elasticsearch:
condition: service_started
mysql:
condition: service_started
ports:
- 8080:8080

###### 3rd-party services
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
# https://www.elastic.co/blog/how-to-make-a-dockerfile-for-elasticsearch
# ###### 3rd-party services
# # https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
# # https://www.elastic.co/blog/how-to-make-a-dockerfile-for-elasticsearch
elasticsearch:
hostname: elasticsearch
image: elasticsearch:1.7.2
environment:
- "ES_JAVA_OPTS=-Xms4g -Xmx4g"
Expand All @@ -24,68 +57,34 @@ services:
memlock:
soft: -1
hard: -1
#restart: "unless-stopped"
ports:
# TODO remap port
- 9200:9200
- 9300:9300
networks:
- labonneboite_elk
- labonneboite_default

kibana:
image: kibana:1.7.2
environment:
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "cluster.name=lbb"
- "bootstrap.memory_lock=true"
- "vm.max_map_count=4g"
ports:
- 5601:5601
networks:
- labonneboite_elk
depends_on:
- elasticsearch
healthcheck:
test: curl --fail localhost:9200/_cat/health || exit 1
interval: 10s
retries: 5
timeout: 2s

# database
mysql:
image: mysql:5.6.36
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
#restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ''
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
<<: *dbenv
ports:
- 3306:3306
networks:
- labonneboite_default
healthcheck:
test: mysql ${MYSQL_DATABASE} --user=${MYSQL_USER} --password='${MYSQL_PASSWORD}' --silent --execute "SELECT 1;"
interval: 10s
retries: 5
timeout: 2s

###### Je Postule
labonneboite:
# Dev tools
adminer:
image: adminer
restart: always
build:
context: .
volumes:
- ./labonneboite/logs:/labonneboite/logs
- .:/labonneboite/src
depends_on:
- elasticsearch
- mysql
expose:
- 8000
# backups:
# restart: always
# build:
# context: .
# dockerfile: dockerfile_backups
# args:
# - ENV_TYPE=${ENV_TYPE:-production}
# - TIMEZONE=${TIMEZONE:-Europe/Paris}
# hostname: backups
# volumes:
# - ./:/home/docker
# - ./backups/home/backups:/home/backups
# - /mnt:/mnt
ports:
- 8000:8080


networks:
labonneboite_elk:
labonneboite_default:
47 changes: 0 additions & 47 deletions docker/uwsgi.ini

This file was deleted.

Loading

0 comments on commit 828e148

Please sign in to comment.