Skip to content

Simple job listing website created using flask and mysql, used mutiple deloyment strategies, used jenkins for ci/cd

License

Notifications You must be signed in to change notification settings

yashsharma127/flask-careers-website-devops

Repository files navigation

Flask Carrer Website

Prerequisites

Before you begin, make sure you have the following installed:

  • Docker
  • Git (optional, for cloning the repository)

Setup

  1. Clone this repository (if you haven't already):

    git clone https://github.com/yashsharma127/flask-careers-website-devops.git
  2. Navigate to the project directory:

    cd your-repo-name
  3. Create a .env file in the project directory to store your MySQL environment variables:

    touch .env
  4. Open the .env file and add your MySQL configuration:

    MYSQL_HOST=mysql
    MYSQL_USER=your_username
    MYSQL_PASSWORD=your_password
    MYSQL_DB=your_database
    

Usage

  1. Start the containers using Docker Compose:

    docker-compose up --build
  2. Access the Flask app in your web browser:

  3. Create the jobs and applications table in your MySQL database:

    • Use a MySQL client or tool (e.g., phpMyAdmin) to execute the following SQL commands:

             CREATE TABLE jobs (
             id INT AUTO_INCREMENT PRIMARY KEY,
             title TEXT,
             location TEXT,
             salary INT
         );
      
      
         CREATE TABLE applications (
             id INT AUTO_INCREMENT PRIMARY KEY,
             job_id INT,
             applicant_name VARCHAR(255) NOT NULL,
             applicant_email VARCHAR(255) NOT NULL,
             application_text TEXT,
             FOREIGN KEY (job_id) REFERENCES jobs(id)
         );
  4. Interact with the app:

    • Visit http://localhost to see the frontend. You can submit new messages using the form.

Cleaning Up

To stop and remove the Docker containers, press Ctrl+C in the terminal where the containers are running, or use the following command:

docker-compose down

To run this two-tier application using without docker-compose

  • First create a docker image from Dockerfile
docker build -t flaskapp .
  • Now, make sure that you have created a network using following command
docker network create twotier
  • Attach both the containers in the same network, so that they can communicate with each other

i) MySQL container

docker run -d --name mysql -v mysql-data:/var/lib/mysql -v ./message.sql:/docker-entrypoint-initdb.d/message.sql --network=twotier -e MYSQL_DATABASE=mydb -e MYSQL_USER=root -e MYSQL_ROOT_PASSWORD="admin" -p 3360:3360 mysql:5.7

ii) Backend container

docker run -d --name flaskapp -v mysql-data:/var/lib/mysql -v ./message.sql:/docker-entrypoint-initdb.d/message.sql --network=twotier -e MYSQL_HOST=mysql -e MYSQL_USER=root -e MYSQL_PASSWORD=admin -e MYSQL_DB=mydb -p 5000:5000 flaskapp:latest

Notes

  • Make sure to replace placeholders (e.g., your_username, your_password, your_database) with your actual MySQL configuration.

  • This is a basic setup for demonstration purposes. In a production environment, you should follow best practices for security and performance.

  • Be cautious when executing SQL queries directly. Validate and sanitize user inputs to prevent vulnerabilities like SQL injection.

  • If you encounter issues, check Docker logs and error messages for troubleshooting.

About

Simple job listing website created using flask and mysql, used mutiple deloyment strategies, used jenkins for ci/cd

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published