File tree 18 files changed +407
-624
lines changed
18 files changed +407
-624
lines changed Original file line number Diff line number Diff line change
1
+ .dockerignore
2
+ Dockerfile
3
+ db.sqlite3
4
+ __pycache__
5
+ * .pyc
6
+ * .pyo
7
+ * .pyd
8
+ .Python
9
+ env
10
+ pip-log.txt
11
+ pip-delete-this-directory.txt
12
+ .tox
13
+ .coverage
14
+ .coverage. *
15
+ .cache
16
+ coverage.xml
17
+ * ,cover
18
+ * .log
19
+ .git
Original file line number Diff line number Diff line change 1
1
FLASK_APP = run.py
2
- SQLALCHEMY_DATABASE_URI = postgresql://user_name:[email protected] :5432/resources
2
+ SQLALCHEMY_DATABASE_URI = postgresql://user_name:change_password@resources-psql:5432/resources-psql
3
+ POSTGRES_USER = user_name
4
+ POSTGRES_PASSWORD = change_password
5
+ POSTGRES_DB = postgres
6
+ DB_HOST = postgresql
7
+ DB_PORT = 5432
8
+ DB_DATABASE = resources-psql
9
+ DB_USERNAME = user_name
10
+ DB_CONNECTION = pgsql
11
+ USER = user_name
12
+ PASSWORD = change_password
13
+ DB = resources-psql
3
14
FLASK_SKIP_DOTENV = 1
4
15
FLASK_ENV = development
Original file line number Diff line number Diff line change @@ -6,18 +6,34 @@ language: python
6
6
sudo : required
7
7
dist : xenial
8
8
python : " 3.7"
9
- # command to install dependencies
10
- before_script :
11
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
- - chmod +x ./cc-test-reporter
9
+ services :
10
+ - docker
11
+
12
+ env :
13
+ - DOCKER_COMPOSE_VERSION=1.22.0
14
+
13
15
install :
14
16
- pip install pipenv
15
17
- pipenv install --dev
16
- # command to run tests
18
+
19
+ before_script :
20
+ - sudo rm /usr/local/bin/docker-compose
21
+ - sudo curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
22
+ - sudo chmod +x /usr/local/bin/docker-compose
23
+ - sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
24
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
25
+ - chmod +x ./cc-test-reporter
26
+ - ' make bg'
27
+ - docker ps -a
28
+ - sleep 30
29
+
17
30
script :
18
- - flake8 app --statistics --count
19
- - pipenv run pytest
20
- - coverage run --source=app/ -m pytest
31
+ - ' make build'
32
+ - ' make test'
33
+ - ' make lint'
34
+
21
35
after_script :
22
36
- coverage xml
37
+ - docker-compose -f docker-compose.yml down
23
38
- if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
39
+
Original file line number Diff line number Diff line change
1
+ FROM python:3.7-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE 1
4
+ ENV PYTHONUNBUFFERED 1
5
+ ENV PIP_NO_BINARY psycopg2
6
+
7
+ WORKDIR /src
8
+ RUN mkdir /static
9
+
10
+ RUN apt-get update \
11
+ && apt-get install -y libpq-dev gcc \
12
+ && rm -rf /var/lib/apt/lists/* \
13
+ && apt-get purge -y --auto-remove gcc \
14
+ && pip install --upgrade pip \
15
+ && pip install alembic \
16
+ && pip install psycopg2-binary \
17
+ && pip install flake8 \
18
+ && pip install Flask \
19
+ && pip install Flask-Migrate \
20
+ && pip install Flask-SQLAlchemy \
21
+ && pip install SQLAlchemy \
22
+ && pip install SQLAlchemy-Utils \
23
+ && pip install PyYAML \
24
+ && pip install flask-pytest \
25
+ && pip install pytest \
26
+ && pip install dataclasses \
27
+ && pip install coverage \
28
+ && pip install pytest-cov
29
+
30
+ COPY . /src
31
+
32
+ EXPOSE 8000
33
+
34
+ CMD ["python" , "run.py" ]
Original file line number Diff line number Diff line change
1
+ DOCKER := docker
2
+ DOCKER_COMPOSE := docker-compose
3
+ RESOURCES_CONTAINER := resources-api
4
+ RESOURCES_DB := resources-psql
5
+ FLASK := flask
6
+
7
+ .PHONY : all
8
+ all : run
9
+
10
+ .PHONY : nuke
11
+ nuke :
12
+ ${DOCKER} system prune -a --volumes
13
+
14
+ .PHONY : minty-fresh
15
+ minty-fresh :
16
+ ${DOCKER_COMPOSE} down --rmi all --volumes
17
+
18
+ .PHONY : rmi
19
+ rmi :
20
+ ${DOCKER} images -q | xargs docker rmi -f
21
+
22
+ .PHONY : rmdi
23
+ rmdi :
24
+ ${DOCKER} images -a --filter=dangling=true -q | xargs ${DOCKER} rmi
25
+
26
+ .PHONY : rm-exited-containers
27
+ rm-exited-containers :
28
+ ${DOCKER} ps -a -q -f status=exited | xargs ${DOCKER} rm -v
29
+
30
+ .PHONY : fresh-restart
31
+ fresh-restart : minty-fresh test run
32
+
33
+ .PHONY : run
34
+ run : build
35
+ ${DOCKER_COMPOSE} run -p 8000:8000 ${RESOURCES_CONTAINER} ${FLASK} run -p 8000 -h 0.0.0.0
36
+
37
+ .PHONY : bg
38
+ bg :
39
+ ${DOCKER_COMPOSE} up --build -d
40
+
41
+ .PHONY : routes
42
+ routes :
43
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK} routes
44
+
45
+ .PHONY : test
46
+ test : build
47
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} py.test --cov=app/ tests/
48
+
49
+ .PHONY : lint
50
+ lint :
51
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} flake8 app --statistics --count
52
+
53
+ .PHONY : help
54
+ help : build
55
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK} --help
56
+
57
+ .PHONY : build
58
+ build :
59
+ ${DOCKER_COMPOSE} build --pull ${RESOURCES_CONTAINER}
60
+
61
+ .PHONY : setup
62
+ setup : bg
63
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK}
64
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK} db-migrate create-tables
65
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK} db stamp head
66
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK} db-migrate init
67
+
68
+ .PHONY : migrate
69
+ migrate : build
70
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK} db migrate
71
+ ${DOCKER_COMPOSE} run ${RESOURCES_CONTAINER} ${FLASK} db upgrade
72
+
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments