From ea0ff4eeca3e24b4c129b0df5464fc79e4811365 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 11 Apr 2019 12:54:15 -0500 Subject: [PATCH] Improvement of docker-compose --- devops/docker/tasking-manager/Dockerfile | 42 ++++++++++++++---------- docker-compose.override.yml | 18 ++++++++++ docker-compose.yml | 29 ++++++++-------- 3 files changed, 55 insertions(+), 34 deletions(-) create mode 100644 docker-compose.override.yml diff --git a/devops/docker/tasking-manager/Dockerfile b/devops/docker/tasking-manager/Dockerfile index a749ca8d66..bf5d734e35 100644 --- a/devops/docker/tasking-manager/Dockerfile +++ b/devops/docker/tasking-manager/Dockerfile @@ -1,31 +1,37 @@ -# Base on Python on Debian stable FROM python:3-stretch -EXPOSE 5000 +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app -# Install dependencies +# Install dependencies for shapely RUN apt-get update \ && apt-get upgrade -y \ && apt-get install -y libgeos-dev \ && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - \ - && apt-get install -y nodejs +# Upgrade pip +RUN pip install --upgrade pip -RUN npm i gulp-cli -g && npm link gulp +ARG branch=develop +RUN git clone --depth=1 git://github.com/hotosm/tasking-manager.git \ + --branch $branch /usr/src/app -# Add code base of the Tasking Manager -ARG defined_branch=develop -RUN git clone --single-branch --branch $defined_branch https://github.com/hotosm/tasking-manager /usr/src/app -WORKDIR /usr/src/app +## API/SERVER CONFIGURATION -# Add and install Python modules for back-end -RUN pip install -r requirements.txt +# Add and install Python modules +RUN pip install --no-cache-dir -r requirements.txt -# Build front-end -RUN cd client && \ - npm install browser-sync closure-util openlayers --save && \ - npm install && gulp build +## CLIENT CONFIGURATION -# Serve application (be aware this runs on port 5000) -CMD python manage.py runserver -h 0.0.0.0 +# Install nodejs. +RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - \ + && apt-get install -y nodejs + +RUN npm install -g gulp-cli karma karma-jasmine karma-chrome-launcher + +RUN cd client && npm link gulp && \ + npm install closure-util --save && \ + npm install && gulp build + +EXPOSE 5000 +CMD ["python", "manage.py", "runserver", "-h", "0.0.0.0"] diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000000..0329cb953c --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,18 @@ +# To use this file, run `docker-compose up`. +version: '3' + +services: + + # Main application + app: + build: ./devops/docker/tasking-manager + volumes: + - .:/usr/src/app + ports: + - "3000:3000" + + # Migration service + migration: + build: ./devops/docker/tasking-manager + volumes: + - .:/usr/src/app diff --git a/docker-compose.yml b/docker-compose.yml index 339a281158..206150f4fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,13 @@ version: '3' services: - # Main application app: - build: devops/docker/tasking-manager + image: hotosm/tasking-manager + container_name: app env_file: tasking-manager.env + environment: + - POSTGRES_ENDPOINT=postgresql depends_on: - postgresql ports: @@ -14,35 +16,30 @@ services: links: - postgresql volumes: - - .:/usr/src/app - - /usr/src/app/client/node_modules - - /usr/src/app/client/assets/styles/css - command: python manage.py runserver -h 0.0.0.0 + - node_modules:/usr/src/app/client/node_modules # Migration service migration: - build: devops/docker/tasking-manager + image: hotosm/tasking-manager env_file: tasking-manager.env + restart: on-failure + environment: + - POSTGRES_ENDPOINT=postgresql depends_on: - postgresql links: - postgresql - volumes: - - .:/usr/src/app command: python manage.py db upgrade # Database postgresql: image: mdillon/postgis:9.6 + container_name: postgresql env_file: tasking-manager.env + # logging: + # driver: none expose: - "5432" - logging: - driver: none - volumes: - - pgdata:/var/lib/postgresql/data volumes: - pgdata: - stage: - downloads: + node_modules: