- Install Docker
- Get the password for the development database from the meep slack channel.
- cd into the api directory
- Build the docker image
sudo docker image build --rm -t meep_api --build-arg db_password=<pwd-from-step-2> -f ./dev.Dockerfile .
- Make sure to replace with the database password you got by asking on Slack, and don't forget the "." at the end of the command! - Start the api in a container:
docker container run -d -p 8000:8000 --rm --name meep_api meep_api
- Go to a browser and enter the url
http://localhost:8000/projects
to see if it worked.
- Install Docker. Compose should be bundled with it.
- Start the containers:
docker-compose up --build -d
. - Seed the development database:
docker container exec meep-backend_api_1 python /meep/api/src/db_operations.py reset dev
. You should only need to do this the first time you run the app. - In a browser, or some other client, type
localhost/api/locations
. If you see a bunch of json data, it worked!
- Shell into database:
password:
docker container exec -it meep-backend_db_1 psql -U meep -h meep-backend_db_1 -d meep_api
supersafe
- Shell into api container
docker container exec -it meep-backend_api_1 /bin/ash
- Shell into nginx container
docker container exec -it meep-backend_web_server_1 /bin/bash
- view log files (similar for api)
docker logs meep-backend_web_server_1
-
Install Docker
-
Build docker image from dockerfile:
docker build -t meep-backend:gunicorn src
-
Create and run a container from the image:
docker run -p 8001:8000 meep-backend:gunicorn
or to allow live editing of the code in the container, dodocker run -p 8001:8000 -v $(pwd)/src:/meep/api/src meep-backend:gunicorn
- On windows, the command for live editing probably won't work. instead of
$(pwd)/src
on the left side of the bind mount, you will have to provide an absolute path to the project folder that contains the Dockerfile (src at the time of writing). After that, there is a chance that you will get a different error. Restart docker and try again. It usually works on the second attempt. Please note that this is a temporary workaround while we find a less annoying way to run the project on windows.
- On windows, the command for live editing probably won't work. instead of
-
In a browser, try typing
http://localhost:8001/locations
to see if it worked.
-
Install python
sudo apt-get install python3
-
sudo apt install virtualenv
-
clone the master branch
git clone [email protected]:codeforkansascity/meep-backend.git
-
move into project root directory
cd meep-backend
-
create a virtual environment in the project root directory
virtualenv venv
-
activate the virtual environment
source venv/bin/activate
-
pip install requiremnets
pip install -r src/requirements.txt
-
Install sqlite3
sudo apt install sqlite3
-
create a sqlite database
touch dev.db
-
set dev database environment variable
export DEV_DATABASE_URL=sqlite:///dev.db
-
Open the database in sqlite with
sqlite3 dev.db;
check to see if it created the tables with.tables
-
try to display data from a table
select * from projects;
you should see a list of projects display -
set flask environment variable to development
export FLASK_ENV=development
-
Set flask app environment variable
export FLASK_APP="src/app:create_app()"
-
run the app
flask run
-
test to see if it worked: in a browser, type
localhost:5000/projects
you should see some json containing project data
- Install python
- Install pip
- Install virtualenv
- clone the master branch
- create a virtual environment in the project root directory
- activate the virtual environment
venv\Scripts\activate
- pip install requirements
pip install -r requirements.txt
- set dev database environment variable
set DEV_DATABASE_URL=sqlite:///dev.db
- set flask environment variable to development
set FLASK_ENV=development
- set flask app variable to point towards app.py
set FLASK_APP=src\app.py
- run the app
flask run
- test to see if it worked: in a browser, type
localhost:5000/projects
you should see some json containing project data
- Start the containers as normal:
docker-compose up --build -d
- Run pytest in the api container to run all discovered tests:
docker exec -it meep-backend_api_1 pytest
- Optionally, shell into the api container as normal (
docker container exec -it meep-backend_api_1 /bin/ash
) and then enter thepytest
command
- Optionally, shell into the api container as normal (
- Add -v command line argument for more detailed view of both failing and passing tests:
pytest -v
- Only run tests in a specific package by specifying its directory:
pytest ../tests/unit
- Only run tests in a specific module by specifying its directory and filename:
pytest ../tests/unit/test_models.py
- Only run a specific test in a specific module:
pytest ../tests/unit/test_models.py::test_insert_location