From 8f0e13fa6d02acf1119c8d3dbb0f7216f325761d Mon Sep 17 00:00:00 2001 From: Gautier P Date: Sun, 3 Jan 2021 11:31:43 +0100 Subject: [PATCH] Update docker to use python3 and add docker-compose --- .gitlab-ci.yml | 18 +++--------------- docker/Dockerfile | 8 ++++---- docker/docker-compose.yml | 11 +++++++++++ flatisfy/data_files/__init__.py | 5 +---- requirements.txt | 3 --- 5 files changed, 19 insertions(+), 26 deletions(-) create mode 100644 docker/docker-compose.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9244cde..a67e9d2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,29 +1,17 @@ before_script: - "pip install -r requirements.txt" - "pip install pylint" - - "curl -sL https://deb.nodesource.com/setup_6.x | bash -" + - "curl -sL https://deb.nodesource.com/setup_10.x | bash -" - "apt-get install -y nodejs jq" - "npm install" -lint:2.7: - image: "python:2.7" - stage: "test" - script: - - "hooks/pre-commit" - -lint:3: +lint: image: "python:3" stage: "test" script: - "hooks/pre-commit" -test:2.7: - image: "python:2.7" - stage: "test" - script: - - python -m flatisfy init-config | jq '.constraints.default.house_types = ["APART"] | .constraints.default.type = "RENT" | .constraints.default.postal_codes = ["75014"]' > /tmp/config.json - - python -m flatisfy test --config /tmp/config.json -test:3: +test: image: "python:3" stage: "test" script: diff --git a/docker/Dockerfile b/docker/Dockerfile index f185b5d..601f4bd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:2 +FROM python:3 MAINTAINER Phyks # Setup layout. @@ -12,10 +12,10 @@ RUN apt-get update && \ # Install latest pip and python dependencies. RUN pip install -U setuptools && \ - pip install html2text simplejson BeautifulSoup + pip install html2text simplejson beautifulsoup4 # Install node.js. -RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \ +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ && apt-get install -y nodejs # Install weboob's code itself. @@ -30,7 +30,7 @@ COPY ./*.sh /home/user/ # Install Flatisfy, set up directories and permissions. RUN cd /home/user \ - && git clone https://framagit.org/phyks/Flatisfy/ ./app \ + && git clone https://framagit.org/phyks/Flatisfy.git/ ./app \ && cd ./app \ && pip install -r requirements.txt \ && npm install \ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..b038337 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3" +services: + app: + build: . + # image: phyks/flatisfy + environment: + - LOCAL_USER_ID=1000 + volumes: + - ./data:/flatisfy + ports: + - "8080:8080" diff --git a/flatisfy/data_files/__init__.py b/flatisfy/data_files/__init__.py index 4e848cf..8f2803b 100644 --- a/flatisfy/data_files/__init__.py +++ b/flatisfy/data_files/__init__.py @@ -16,10 +16,7 @@ from flatisfy.models.postal_code import PostalCode from flatisfy.models.public_transport import PublicTransport from flatisfy.tools import normalize_string -if sys.version_info >= (3, 0): - import csv -else: - from backports import csv +import csv LOGGER = logging.getLogger(__name__) diff --git a/requirements.txt b/requirements.txt index 794d850..da794c0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,9 @@ alembic appdirs arrow -backports.csv; python_version < '3.0' bottle bottle-sqlalchemy canister -enum34; python_version < '3.4' -functools32; python_version < '3.2.3' future imagehash mapbox