Skip to main content

Build Flask App(Kanbanboard) using Docker and Docker Compose

 A Kanban board is a project management tool designed to help visualize work, manage project tasks, workflows and communication. In this challenge, you are going to write the unit test cases for the given Kanban board Flask application using Pytest and deploy the application using Docker Compose.


Instructions:

1. Write the unit test cases using Pytest testing framework in the following path

2. Refer 'test.py' file for further instructions.

3. Commands to Execute:

- 'export FLASK APP-app.py' to set an environment variable.

- 'python3 m flask run' to run the Flask application. 

- 'python3 m pytest test.py' to run the test cases.

4. Once you done with test cases. Deploy the Kanban board Flask application in Docker using Docker Compose.

5. Create a 'Dockerfile' to dockerize the Kanban board Flask application with 'python alpine3.7 as its base image named 'kanbanboard_app_image". 

6. Create 'docker-compose.yml file to create a service named 'app' with the docker image (kanbanboard_app_image), container named "kanbanboard_app_container', connect a bridge network named 'app_network', attach a volume named 'app_volume' and deploy the application in 5005 port. 

7. Visit "http://localhost:5005/" URL in the browser and ensure that the application is running successful.


Step1: Create a docker file for the flask app

Dockerfile :

FROM python:3.7-alpine

WORKDIR /app

COPY . /app

RUN pip install requirement.txt

ENV FLASK_APP=app.py

ENV FLASK_RUN_HOST=0.0.0.0

ENV FLASK_RUN_PORT=5000

ENV FLASK_ENV=development

CMD ["flask", "run"]


## test the docker image that to be built from dockerfile

docker build -t kanbanboard_app_image .

docker run kanbanboard_app_image

docker ps -a

docker stop <container-id>




Step2:  Create a docker-compose.yml file

docker-compose.yml:

version: '3.3'

services:

app:

image: kanbanboard_app_image

build: ./app

container_name: kanbanboard_app_container

ports:

- "5005:5005"

networks:

- app_network

volumes:

- app_volume:/app

networks:

app_network:

driver: bridge

volumes:

app_volume:


## test and run using docker compose

docker compose build --up


Comments

Popular posts from this blog

Kubernetes2

  Challenge 2 ConfigMaps: Step-1: To create a ConfigMap named 'fresco-config' with the key-value pair SERVER_URL= https://www.fresco.me , use the following command: kubectl create configmap fresco-config --from-literal=SERVER_URL=https://www.fresco.me To verify if the ConfigMap is created, use the following command: kubectl get configmap fresco-config Step-2: To create an nginx pod with the environmental variable SERVER_URL_ENV using the ConfigMap created earlier, use the following YAML template: apiVersion: v1 kind: Pod metadata: name: fresco-nginx-pod spec: containers: - name: fresco-nginx-container image: nginx env: - name: SERVER_URL_ENV valueFrom: configMapKeyRef: name: fresco-config key: SERVER_URL Deploy the above file you can name it deployment.yaml and use the command: kubectl apply -f deployment.yaml To test your configuration by executing the following command: ...

Docker + Kubernetes + Ansible

  Docker + Kubernetes + Ansible ----------------------------------------------------------------------------------------------------------------------------- Web Application Deployment using Kubernetes and Ansible A Flask application named "application.py" is given in the path Run the given setup.sh file given in the path to install the required dependencies be the challenge. 1. Start Minikube and sync host Docker with Minikube Docker. Note: If you get any errors while starting Minikube, please do try again by running the command to start Minikube. 2. Create a Dockerfile in the path and dockerize the given 'Flask' application as 'webapp-img' using 'python:alpine3.7' as its base image. 3. Create a 'deployment.yml' file in the path to create a Kubernetes deployment object named "web-deployment" with 3 replicas which uses the 'webapp-img' and runs a container named "webapp-container". Add Label "app=webapp" an...

Mini-Projects for Docker, Docker Swarm

 Mini-Projects for Docker Challenge 1 Welcome to the Docker challenge, your task is to follow the below steps and complete them successfully. Step 1: Pull latest nginx image Step 2: Create a new bridge 'bridge_sample' Step 3: Run a couple of images (Cont1 and Cont2) and connect these to the new bridge created. Now try to ping from cont1 to cont2 to verify connectivity. Step 4: Stop containers Step 5: Remove network, containers, and images using docker commands Note: Execute "history -w" in the terminal before submitting the scenario. Before moving to Answers try to solve yourself... Let's get started... Step 1: Pull latest nginx image docker pull nginx:latest Step 2: Create a new bridge 'bridge_sample' docker network create bridge_sample Step 3: Run containers and connect them to the new bridge docker run -d --name Cont1 --network bridge_sample nginx:latest docker run -d --name Cont2 --netw...