A minimal dockerized URL shortener API.
Before building and running the services;
let's create .env
file in order to set environment variables.
echo "
APP_HOST=0.0.0.0
APP_PORT=8000
FLASK_APP=app
FLASK_ENV=development
SECRET_KEY=VerySecretKey
" > .env
.env
file must be created in the top-most directory (along withdocker-compose.yml
).
Now we can build the app image and start the services.
docker-compose build
docker-compose up -d
You can easily run the tests by running:
docker-compose run --rm app pytest --verbose --cov=.
curl -v -X GET http://localhost:8000/<string:code>
curl -v -X POST -d url=http://example.com http://localhost:8000/shorten
├── Dockerfile
├── README.md
├── app
│ ├── app
│ │ ├── __init__.py
│ │ ├── models.py
│ │ ├── settings.py
│ │ ├── utils.py
│ │ └── views.py
│ ├── pytest.ini
│ ├── requirements.txt
│ └── tests
│ ├── __init__.py
│ ├── test_utils.py
│ └── test_views.py
├── docker-compose.override.yml
└── docker-compose.yml