├── Dockerfile ├── README.md ├── data_processing_script.py ├── database.db └── requirements.txt /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9 2 | 3 | WORKDIR /app 4 | 5 | COPY ./requirements.txt /app/requirements.txt 6 | RUN pip install -r requirements.txt 7 | 8 | COPY . /app 9 | 10 | CMD ["python", "data_processing_script.py"] 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Data Processing Application with Docker 2 | 3 | This repository contains a simple data processing application that utilizes Docker for containerization. The application processes data using Python and stores it in a SQLite database. 4 | 5 | ## Usage 6 | 7 | ### Prerequisites 8 | 9 | Make sure you have Docker installed on your system. If you haven't already, you can download and install Docker from [here](https://www.docker.com/get-started). 10 | 11 | ### Clone the repo 12 | 13 | Clone this repository, run the following command: 14 | 15 | ```bash 16 | git clone https://github.com/Sefdine/Docker_initialization.git 17 | ``` 18 | 19 | ### Build an image based on the Dockerfile 20 | 21 | Open the terminal and go in the folder where you have your project. Run this command : 22 | 23 | ``` 24 | docker build -t data-processing-app . 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /data_processing_script.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sqlite3 3 | import pandas as pd 4 | 5 | # Get the absolute path to the database file 6 | db_path = os.path.join(os.path.dirname(__file__), 'database.db') 7 | 8 | # Simulated data ingestion 9 | data = { 10 | 'Name': ['John', 'Anna', 'Peter', 'Linda'], 11 | 'Age': [35, 28, 29, 42] 12 | } 13 | df = pd.DataFrame(data) 14 | 15 | # Data processing 16 | processed_data = df.groupby('Name').mean() 17 | 18 | # Storing data in SQLite database 19 | conn = sqlite3.connect(db_path) 20 | processed_data.to_sql('processed_data', conn, if_exists='replace', index=False) 21 | conn.close() 22 | 23 | print("Data processing and storage complete.") 24 | -------------------------------------------------------------------------------- /database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sefdine/Docker_initialization/94714c8856830e3da9ac1c598809a6d049d1f9c1/database.db -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pandas 2 | db-sqlite3 --------------------------------------------------------------------------------