This boilerplate is designed as a tutorial for deploying a Flask application with additional services.
New to Docker? Go to Getting Started
This application contains the following services:
- Flask Application
- PostgresSQL
- MinIO
- Redis
- A worker
The default is to use KeyCloak for authentication. I have commented out the decorators for requiring a login here and here. This is to help people new to authentication.
All environment variables used in the deployment are located in the .env file.
-
Using prebuilt images
docker-compose up
-
Building images
docker-compose -f docker-compose-development.yml up
- Application:
localhost:5000
- MinIO:
localhost:9000
I am assuming if you are new to Docker you are probably using a Windows machine. This is not a bad thing, in fact often at work it is all you get. You will need to install some services to use this repo. I will assume you have a GitHub account (after all you are looking at GitHub) and I will provide you a list of software to install (and recommend others).
- Install Docker.
- Install Git
Now the hard part is out of the way, go ahead and ensure Docker is running. For this I will assume you are using a Windows machine. In the bottom left-hand corner click the windows start
button. Type git
in the search menu and select Git Bash
Git Bash
. Once the black window opens, type docker ps
and you should get something back that looks like this:
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
If you got something that looks like this, then you most likely need to start Docker. In the bottom left-hand corner click the windows start
button. Type docker
and select Docker Desktop
. This will get it running and repeat the step before.
There are five Docker images used in this techstack. You can pull them using the following commands in any of your favorite OS's
docker pull <image_name>
For this you will need to run this application stack you will need to run the following lines of code:
- Note if you are going to paste into Git Bash,
Shift+Insert
is paste.
docker pull statculus/boilerplate_app:latest
docker pull statculus/boilerplate_worker:latest
docker pull bitnami/postgresql:latest
docker pull bitnami/minio:latest
docker pull bitnami/postgresql:latest
It might take a while, but now you will have five images saved locally.
Run the following command from the base directory of this repo.
docker-compose up
There will be a bunch of logs appear, but that is normal. After approximately 30 seconds your application will be running.
Visit http://localhost:5000 to see your application. Under Create Form
select Create New Form
. Type some text and click Submit
. Next visit http://localhost:9000 and sign into MinIO. The default Access Key is bryanisawesome and Secret Key is bryanrocks. Under the results
bucket you will see a text file with the text you just typed. The name of the file will be dd-mm-yyyy_HH:MM:SS_Bryan_Rocks.txt
Run the following command from the base directory of this repo:
docker-compose up
If you have not pulled the images already, they will be pulled and start running!
Run the following command from the base directory of this repo:
docker-compose -f docker-compose-development.yml up
Your images will build locally (might take some time) and then start running.