devops-exercises/challenges/flask_container_ci/README.md

58 lines
2.1 KiB
Markdown
Raw Normal View History

2019-12-21 12:26:41 +01:00
Your mission, should you choose to accept it, involves fixing the app in this directory, containerize it and set up a CI for it.
Please read carefully all the instructions.
## Installation
1. Create a virtual environment with `python3 -m venv challenge_venv`
2. Activate it with `source challenge_venv/bin/activate`
2019-12-21 18:50:04 +01:00
3. Install the requirements in this directory `pip install -r requirements.txt`
2019-12-21 12:26:41 +01:00
## Run the app
2019-12-21 18:50:04 +01:00
If any of the following steps is not working, it is expected from you to fix them
2019-12-21 12:26:41 +01:00
1. Run `export FLASK_APP=app/app.py`
1. To run the app execute `flask run`. If it doesn't works, fix it
2019-12-21 18:50:04 +01:00
3. Access `http://127.0.0.1:5000`. You should see the following
```
{
"resources_uris": {
"user": "/users/<username>",
"users": "/users"
},
"current_uri": "/"
}
```
2019-12-21 12:26:41 +01:00
2019-12-21 18:50:04 +01:00
4. You should be able to access any of the resources and get the following data:
* /users/<username> - data on the specific chosen user
* /users - all users data
2019-12-21 12:26:41 +01:00
## Containers
Using Docker or Podman, containerize the flask app so users can run the following two commands:
```
docker build -t app:latest /path/to/Dockerfile
docker run -d -p 5000:5000 app
```
1. You can use any image base you would like
2. Containrize only what you need for running the application, nothing else.
## CI
Great, now that we have a working app and also can run it in a container, let's set up a CI for it so it won't break again in the future
2019-12-21 18:50:04 +01:00
In current directory you have a file called tests.py which includes the tests for the app. What is expected from you is:
2019-12-21 12:26:41 +01:00
2019-12-21 18:50:04 +01:00
1. The CI should run the app tests. You are free to choose whatever CI system or service you prefer.
2019-12-21 12:26:41 +01:00
2. There should be some kind of test for the Dockerfile you wrote
2019-12-21 18:50:04 +01:00
3. Add additional unit test (or another level of tests) for testing the app
### Guidelines
* Except the app functionality, you can change whatever you want - structure, tooling, libraries, ... If possible add `notes.md` file which explains reasons, logic, thoughts and anything else you would like to share
* The CI part should include the source code for the pipeline definition