https://github.com/sdatko/flask-container-ci2
This repository contains my solution for `flask_container_ci2` exercise from Arie Bregman's `devops-exercises` project.
https://github.com/sdatko/flask-container-ci2
bash docker flask pytest python tox unittest
Last synced: about 2 months ago
JSON representation
This repository contains my solution for `flask_container_ci2` exercise from Arie Bregman's `devops-exercises` project.
- Host: GitHub
- URL: https://github.com/sdatko/flask-container-ci2
- Owner: sdatko
- Created: 2020-01-19T16:51:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-11-23T12:04:23.000Z (over 4 years ago)
- Last Synced: 2025-02-09T16:42:51.046Z (over 1 year ago)
- Topics: bash, docker, flask, pytest, python, tox, unittest
- Language: Python
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

Your mission, should you choose to accept it, involves developing an app, containerize it and set up a CI for it.
Please read carefully all the instructions.
If any of the following steps is not working, it is expected from you to fix them.
## Installation
1. Create a virtual environment with `python3 -m venv challenge_venv`.
2. Activate it with `source challenge_venv/bin/activate`.
3. Install the requirements in this directory `pip install -r requirements.txt`.
## Run the app
1. Move to `exercises/flask_container_ci2` directory, if you are not already there.
2. Run `export FLASK_APP=app/main.py`.
3. To run the app execute `flask run`. If it doesn't works, fix it.
4. Access `http://127.0.0.1:5000`. You should see the following:
```
{
"current_uri": "/",
"example": "/matrix/'123n456n789'",
"resources": {
"column": "/columns//",
"matrix": "/matrix/",
"row": "/rows//"
}
}
```
4. You should be able to access any of the resources and get the following data:
* `/matrix/`
for example, for `/matrix/123n456n789` the user will get:
```
1 2 3
4 5 6
7 8 9
```
* `/columns//`
for example, for `/columns/123n456n789/2` the user will get:
```
2
5
8
```
* `/rows//`
for example, for `/rows/123n456n789/1` the user will get:
```
1 2 3
```
## Containers
Using Docker or Podman, containerize the flask app so users can run the following two commands:
```
docker build -t app:latest /path/to/directory-containing-Dockerfile
docker run -d -p 5000:5000 app
```
1. You can use any image base you would like.
2. Containerize 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.
In current directory you have a file called tests.py which includes the tests for the app. What is required from you, is:
1. Write a CI pipeline that will run the app tests. You are free to choose whatever CI system or service you prefer. Use `python tests.py` for running the tests.
2. There should be some kind of test for the Dockerfile you wrote.
3. Add additional unit test (or any other 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.