From bf8904fb2d252fee95f7675129e589d2a4137a54 Mon Sep 17 00:00:00 2001 From: SamR1 Date: Wed, 10 Jan 2018 22:36:31 +0100 Subject: [PATCH] travis config init --- .travis.yml | 26 ++++++++++++ docker-compose-ci.yml | 44 ++++++++++++++++++++ docker-compose.yml => docker-compose-dev.yml | 0 mpwo_api/Dockerfile-ci | 17 ++++++++ mpwo_client/Dockerfile-ci | 25 +++++++++++ 5 files changed, 112 insertions(+) create mode 100644 .travis.yml create mode 100644 docker-compose-ci.yml rename docker-compose.yml => docker-compose-dev.yml (100%) create mode 100644 mpwo_api/Dockerfile-ci create mode 100644 mpwo_client/Dockerfile-ci diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..f3495291 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +sudo: required + +services: + - docker + +env: + global: + - DOCKER_COMPOSE_VERSION=1.14.0 + +before_install: + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin + +before_script: + - export APP_SETTINGS="project.config.TestingConfig" + - export DATABASE_TEST_URL=postgresql://postgres:@localhost/users_test + - export REACT_APP_USERS_SERVICE_URL=http://127.0.0.1:3000/api/ + - docker-compose -f docker-compose-ci.yml up --build -d + +script: + - docker-compose -f docker-compose-ci.yml run api flask init_db + +after_script: +- docker-compose down diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml new file mode 100644 index 00000000..12f4d21a --- /dev/null +++ b/docker-compose-ci.yml @@ -0,0 +1,44 @@ +version: '3.3' + +services: + + db: + container_name: db + build: https://github.com/SamR1/mpwo.git#master:mpwo_api/db + ports: + - 5435:5432 + environment: + - POSTGRES_USER=mpwo + - POSTGRES_PASSWORD=mpwo + + api: + container_name: api + build: + context: https://github.com/SamR1/mpwo.git#master:mpwo_api + dockerfile: Dockerfile-ci + ports: + - 5001:5000 + environment: + - FLASK_APP=server.py + - FLASK_DEBUG=1 + - APP_SETTINGS=mpwo_api.config.TestingConfig + - DATABASE_URL=postgres://mpwo:mpwo@db:5432/mpwo_test + depends_on: + - db + links: + - db + + client: + container_name: client + build: + context: https://github.com/SamR1/mpwo.git + dockerfile: ./mpwo_client/Dockerfile-ci + args: + - NODE_ENV=development + - REACT_APP_USERS_SERVICE_URL=${REACT_APP_USERS_SERVICE_URL} + ports: + - 3007:3000 + depends_on: + - api + links: + - api diff --git a/docker-compose.yml b/docker-compose-dev.yml similarity index 100% rename from docker-compose.yml rename to docker-compose-dev.yml diff --git a/mpwo_api/Dockerfile-ci b/mpwo_api/Dockerfile-ci new file mode 100644 index 00000000..9e706603 --- /dev/null +++ b/mpwo_api/Dockerfile-ci @@ -0,0 +1,17 @@ +FROM python:3.6.3 + +# set working directory +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +# add requirements +ADD ./requirements.txt /usr/src/app/mpwo_api/requirements.txt + +# install requirements +RUN pip install -r mpwo_api/requirements.txt + +# add app +ADD . /usr/src/app + +# run server +CMD flask run --with-threads -h 0.0.0.0 diff --git a/mpwo_client/Dockerfile-ci b/mpwo_client/Dockerfile-ci new file mode 100644 index 00000000..8af5cf7d --- /dev/null +++ b/mpwo_client/Dockerfile-ci @@ -0,0 +1,25 @@ +FROM node:latest + +# set working directory +RUN mkdir /usr/src/app +WORKDIR /usr/src/app + +# add `/usr/src/app/node_modules/.bin` to $PATH +ENV PATH /app/node_modules/.bin:$PATH + +# add environment variables +ARG REACT_APP_USERS_SERVICE_URL +ARG NODE_ENV +ENV NODE_ENV $NODE_ENV +ENV REACT_APP_USERS_SERVICE_URL $REACT_APP_USERS_SERVICE_URL + +# install and cache app dependencies +ADD package.json /usr/src/app/package.json +RUN npm install --silent +RUN npm install react-scripts -g + +# add app +ADD . /usr/src/app/ + +# start app +CMD ["npm", "start"]