Add new challenge
This commit is contained in:
34
challenges/flask_container_ci/README.md
Normal file
34
challenges/flask_container_ci/README.md
Normal file
@ -0,0 +1,34 @@
|
||||
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`
|
||||
3. Install requirements.txt `pip install -r requirements.txt`
|
||||
|
||||
## Run the app
|
||||
|
||||
1. Run `export FLASK_APP=app/app.py`
|
||||
1. To run the app execute `flask run`. If it doesn't works, fix it
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
1. The CI should run the tests in the app directory
|
||||
2. There should be some kind of test for the Dockerfile you wrote
|
||||
2. Add additional unit test (or another level of tests)
|
9
challenges/flask_container_ci/app/app.py
Normal file
9
challenges/flask_container_ci/app/app.py
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
from flask import Flask
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def hello_world():
|
||||
return 'Hello, World!'
|
12
challenges/flask_container_ci/app/config.py
Normal file
12
challenges/flask_container_ci/app/config.py
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import os
|
||||
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
SECRET_KEY = 'shhh'
|
||||
CSRF_ENABLED = True
|
||||
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
|
||||
|
25
challenges/flask_container_ci/app/tests.py
Normal file
25
challenges/flask_container_ci/app/tests.py
Normal file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from config import basedir
|
||||
from app import app
|
||||
from app import db
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
app.config['TESTING'] = True
|
||||
app.config['WTF_CSRF_ENABLED'] = False
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db')
|
||||
self.app = app.test_client()
|
||||
db.create_all()
|
||||
|
||||
def tearDown(self):
|
||||
db.session.remove()
|
||||
db.drop_all()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user