Skip to content

Commit

Permalink
Merge pull request #2181 from unicef/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
domdinicola authored Mar 7, 2019
2 parents 3b26a98 + c9fadf1 commit 48b90b6
Show file tree
Hide file tree
Showing 182 changed files with 4,112 additions and 5,189 deletions.
52 changes: 5 additions & 47 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
working_directory: ~/code
# The primary container is an instance of the first list image listed. Your build commands run in this container.
docker:
- image: unicef/etools:test-base-p3
- image: unicef/etools:test-base-p3-v2
environment:
PGHOST: 127.0.0.1
DATABASE_URL: "postgis://postgres:postgres@localhost:5432/circle_test"
Expand All @@ -18,14 +18,13 @@ jobs:
steps:
- checkout
- restore_cache:
key: deps2-{{ .Branch }}--{{ checksum "src/requirements/test.txt" }}-{{ checksum ".circleci/config.yml" }}
key: deps2-{{ .Branch }}--{{ checksum "Pipfile.lock" }}-{{ checksum ".circleci/config.yml" }}
- run:
name: Run Tests
command: |
pip install tox
tox -re d20,report
tox -e d21,report
- save_cache:
key: deps2-{{ .Branch }}--{{ checksum "src/requirements/test.txt" }}-{{ checksum ".circleci/config.yml" }}
key: deps2-{{ .Branch }}--{{ checksum "Pipfile.lock" }}-{{ checksum ".circleci/config.yml" }}
paths:
- "env1"
- /root/.cache/pip
Expand All @@ -34,55 +33,14 @@ jobs:
destination: coverage

build_and_deploy:
working_directory: ~/code
# The primary container is an instance of the first list image listed. Your build commands run in this container.
docker:
- image: unicef/etools:test-base-p3
environment:
PGHOST: 127.0.0.1
DATABASE_URL: "postgis://postgres:postgres@localhost:5432/circle_test"
- image: circleci/postgres:9.5-alpine-postgis
environment:
POSTGRES_USER: postgres
PGUSER: postgres
POSTGRES_DB: circle_test
POSTGRES_PASSWORD: postgres
machine: true
steps:
- checkout
- setup_remote_docker:
reusable: true
exclusive: true
- run:
name: Install Docker client
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- run:
name: see all docker containers
command: |
docker ps -a
- run:
name: see if postgres is available locally
command: |
pg_isready
- run:
name: Start DB Image
command: |
docker run --name docker-postgres -e PGUSER=postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=circle_test -d circleci/postgres:9.5-alpine-postgis
- run:
name: Building the image
command: |
TAG=${CIRCLE_BRANCH}
docker build -t unicef/etools:$TAG .
- run:
name: Test in the image
command: |
TAG=${CIRCLE_BRANCH}
HOSTIP=`/sbin/ip route|awk '/default/ { print $3 }'`
echo "Skipping tests in image for now... to be fixed"
- run:
name: Pushing to Docker Hub
command: |
Expand Down
62 changes: 33 additions & 29 deletions .circleci/images/primary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
FROM python:3.6.4-jessie
# python:3.6.4-jessie has python 2.7 and 3.6 installed, and packages
# available to install 3.4
FROM python:3.6.4-alpine
# test-base-p3-v2
RUN echo "http://dl-3.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN apk update
RUN apk add --upgrade apk-tools

# Install dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
build-essential \
libcurl4-openssl-dev \
libjpeg-dev \
vim \
ntp \
git-core
RUN apt-get install -y --no-install-recommends \
python-pip \
postgresql-client \
libpq-dev \
python3-dev
RUN apt-get install -y --no-install-recommends \
python-gdal \
gdal-bin \
libgdal-dev \
libgdal1h \
libgdal1-dev \
RUN apk add \
--update alpine-sdk

RUN apk add openssl \
ca-certificates \
libressl2.7-libcrypto
RUN apk add \
libxml2-dev \
libxslt-dev \
xmlsec1
xmlsec-dev
RUN apk add postgresql-dev \
libffi-dev\
jpeg-dev

RUN apk add --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \
gdal \
gdal-dev \
py-gdal \
geos \
geos-dev \
gcc \
g++

RUN apk add bash

RUN pip install virtualenv
RUN pip install --upgrade \
setuptools \
pip \
wheel \
pipenv \
tox

# http://gis.stackexchange.com/a/74060
ENV CPLUS_INCLUDE_PATH /usr/include/gdal
ENV C_INCLUDE_PATH /usr/include/gdal
ENV REQUIREMENTS_FILE base.txt
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,3 @@ src/etools/config/settings/custom.py
.tox
.pytest_cache
coverage.xml
Pipfile
90 changes: 49 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
FROM python:3.6.4-jessie
# python:3.6.4-jessie has python 2.7 and 3.6 installed, and packages
# available to install 3.4

# Install dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
build-essential \
libcurl4-openssl-dev \
libjpeg-dev \
vim \
ntp \
libpq-dev
RUN apt-get install -y --no-install-recommends \
git-core
RUN apt-get install -y --no-install-recommends \
python3-dev \
python-software-properties \
python-setuptools
RUN apt-get install -y --no-install-recommends \
postgresql-client \
libpq-dev \
python-psycopg2
RUN apt-get install -y --no-install-recommends \
python-gdal \
gdal-bin \
libgdal-dev \
libgdal1h \
libgdal1-dev \
FROM python:3.6.4-alpine as builder

RUN echo "http://dl-3.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN apk update
RUN apk add --upgrade apk-tools

RUN apk add \
--update alpine-sdk

RUN apk add openssl \
ca-certificates \
libressl2.7-libcrypto
RUN apk add \
libxml2-dev \
libxslt-dev \
xmlsec1
xmlsec-dev
RUN apk add postgresql-dev \
libffi-dev\
jpeg-dev

RUN apk add --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \
gdal \
gdal-dev \
py-gdal \
geos \
geos-dev \
gcc \
g++

RUN pip install --upgrade \
setuptools \
pip \
wheel
wheel \
pipenv

# http://gis.stackexchange.com/a/74060
ENV CPLUS_INCLUDE_PATH /usr/include/gdal
ENV C_INCLUDE_PATH /usr/include/gdal
ENV REQUIREMENTS_FILE base.txt
WORKDIR /etools/
ADD Pipfile .
ADD Pipfile.lock .
RUN pipenv install --system --ignore-pipfile --deploy

ADD src/requirements/*.txt /pip/
ADD src/requirements/$REQUIREMENTS_FILE /pip/app_requirements.txt
RUN pip install -f /pip -r /pip/app_requirements.txt

ENV PYTHONUNBUFFERED 1
FROM python:3.6.4-alpine

RUN echo "http://dl-3.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN apk update
RUN apk add --upgrade apk-tools
RUN apk add postgresql-client
RUN apk add openssl \
ca-certificates \
libressl2.7-libcrypto
RUN apk add geos \
gdal --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/

ADD src /code/
ADD manage.py /code/manage.py
ENV PYTHONPATH /code
ADD manage.py /code/manage.py

WORKDIR /code/

COPY --from=builder /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /code
ENV DJANGO_SETTINGS_MODULE etools.config.settings.production
RUN SECRET_KEY=not-so-secret-key-just-for-collectstatic DISABLE_JWT_LOGIN=1 python manage.py collectstatic --noinput
78 changes: 36 additions & 42 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,53 +1,47 @@
FROM python:3.6.4-jessie
# python:3.6.4-jessie has python 2.7 and 3.6 installed, and packages
# available to install 3.4

# Install dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
build-essential \
libcurl4-openssl-dev \
libjpeg-dev \
vim \
ntp \
libpq-dev
RUN apt-get install -y --no-install-recommends \
git-core
RUN apt-get install -y --no-install-recommends \
python3-dev \
python-software-properties \
python-setuptools
RUN apt-get install -y --no-install-recommends \
postgresql-client \
libpq-dev \
python-psycopg2
RUN apt-get install -y --no-install-recommends \
python-gdal \
gdal-bin \
libgdal-dev \
libgdal1h \
libgdal1-dev \
FROM python:3.6.4-alpine

RUN echo "http://dl-3.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN apk update
RUN apk add --upgrade apk-tools

RUN apk add \
--update alpine-sdk

RUN apk add openssl \
ca-certificates \
libressl2.7-libcrypto
RUN apk add \
libxml2-dev \
libxslt-dev \
xmlsec1
xmlsec-dev
RUN apk add postgresql-dev \
libffi-dev\
jpeg-dev

RUN apk add --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \
gdal \
gdal-dev \
py-gdal \
geos \
geos-dev \
gcc \
g++

RUN pip install --upgrade \
setuptools \
pip \
wheel

wheel \
pipenv

# http://gis.stackexchange.com/a/74060
ENV CPLUS_INCLUDE_PATH /usr/include/gdal
ENV C_INCLUDE_PATH /usr/include/gdal
ENV REQUIREMENTS_FILE=test.txt

ADD src/requirements/*.txt /pip/
ADD src/requirements/$REQUIREMENTS_FILE /pip/app_requirements.txt
RUN pip install -f /pip -r /pip/app_requirements.txt
WORKDIR /etools/
ADD Pipfile .
ADD Pipfile.lock .
RUN pipenv install --dev --system --ignore-pipfile
RUN apk add bash

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /code
ENV DJANGO_SETTINGS_MODULE etools.config.settings.local

VOLUME "./:/code/"
WORKDIR /code/

ENV DJANGO_SETTINGS_MODULE etools.config.settings.local
Loading

0 comments on commit 48b90b6

Please sign in to comment.