File | Date | Author | Commit |
---|---|---|---|
ci-cd | 2021-09-19 | Gabriele | [8e6e98] Adding the CI/CD example |
local | 2021-09-19 | Gabriele | [fac0ee] local tests |
LICENSE | 2021-09-19 | Gabriele Gatto | [9f16f2] Initial commit |
README.md | 2021-09-19 | Gabriele Gatto | [9661c0] Update README.md |
A Docker Python-Flask with NGINX for the AUTH project
@maintainer G.Gatto 2021 - www.garanet.net
repo from: https://github.com/garanet/Docker-Python-Flask-with-NGINX-for-AUTH
Tested on a MacOsx with Docker + Kuberneters (Docker-Desktop)
This project shows how you can create a python flask api with docker behind a reverse proxy to protect different /endpoints.
It could be easily integrated with different pipeline to trigger when a dockerfile or your app.py changes.
In the main folder you'll find a bash script to create or shutdown the containers.
The script also is checking with a curl command if the containers are working or not.
In order to run it, You need to have installed on your PC/MacOsX/Linux, Docker and docker-compose.
FILE/FOLDER | ASCII | ARGUMENTS |
---|---|---|
deploy_me.sh | 'To exec from your terminal with arguments' |
'start = build&start containers'; 'stop = stop containers;' 'remove = stop&remove containers' |
docker-compose.yml | "The directives for the 2 containers" |
- |
/garanet/ | Include Dockerfile, Flask Application |
- |
/nginx/ | Include Dockerfile, Nginx conf, htpasswd |
- |
Inside the ci-cd folder you'll find an syntax exanple for the gitlab-ci pipeline.
You have to run it form your terminal, make sure the script has the exec privileges, otherwise run
~:# cd local/
~:# chmod a+x deploy_me.sh
~:# ./deploy_me.sh start
Running tha above command, the Docker will create 2 docker containers locally to expose 3 endpoints API with FLASK.
From your browser you can retreive the urls:
GET:
POST:
From your terminal you can POST a JSON via curl like:
~:# curl --user guest --header "Content-Type: application/json" --request POST --data '{"key":"POST JSON WORKS"}' http://localhost:5000/getmyfile
The default username and password are guest / guest.
You can change it generating a htapasswd file from the command line like:
~:# htpasswd -c PATH/.htapasswd username
~:#./deploy_me.sh stop
~:#./deploy_me.sh remove