travis config init

This commit is contained in:
SamR1 2018-01-10 22:36:31 +01:00
parent 1a6ae7c159
commit bf8904fb2d
5 changed files with 112 additions and 0 deletions

26
.travis.yml Normal file
View File

@ -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

44
docker-compose-ci.yml Normal file
View File

@ -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

17
mpwo_api/Dockerfile-ci Normal file
View File

@ -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

25
mpwo_client/Dockerfile-ci Normal file
View File

@ -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"]