diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c07a7e92 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +# Use an official Python runtime as a parent image. +FROM python:3.8-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the entire project into the container +COPY . /app + +# Make the entrypoint script executable +RUN chmod +x /app/entrypoint.sh + +# Install system dependencies and ODBC driver +RUN apt-get update && apt-get install -y \ + unixodbc unixodbc-dev odbcinst odbcinst1debian2 libpq-dev gcc && \ + apt-get install -y gnupg && \ + apt-get install -y wget && \ + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ + wget -qO- https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ + apt-get update && \ + ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \ + apt-get purge -y --auto-remove wget && \ + apt-get clean + +# Install pip and setuptools +RUN pip install --upgrade pip setuptools + +# Install Python packages specified in requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt + +# Expose port +EXPOSE 5000 + +# Define Startup Command using entrypoint script +ENTRYPOINT ["/app/entrypoint.sh"] + \ No newline at end of file diff --git a/README.md b/README.md index 08407749..b1ddcdda 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Web-App-DevOps-Project +# Web-App-DevOps-Project - Dean Foulds Welcome to the Web App DevOps Project repo! This application allows you to efficiently manage and track orders for a potential business. It provides an intuitive user interface for viewing existing orders and adding new ones. diff --git a/app.py b/app.py index 50f4e29d..22d93721 100644 --- a/app.py +++ b/app.py @@ -46,7 +46,7 @@ class Order(Base): product_quantity = Column('Product Quantity', Integer) order_date = Column('Order Date', DateTime) shipping_date = Column('Shipping Date', DateTime) - + delivery_date = Column('Delivery Date', DateTime) # define routes # route to display orders @app.route('/') diff --git a/db.py b/db.py new file mode 100644 index 00000000..1c987540 --- /dev/null +++ b/db.py @@ -0,0 +1,17 @@ +from sqlalchemy import Column, Integer, String, DateTime +from sqlalchemy.orm import declarative_base + +Base = declarative_base() + +class Order(Base): + __tablename__ = 'orders' + + date_uuid = Column(DateTime) + user_id = Column(Integer, primary_key=True) + card_number = Column(String) + store_code = Column(String) + product_code = Column(String) + product_quantity = Column(Integer) + order_date = Column(DateTime) + shipping_date = Column(DateTime) + delivery_date = Column(DateTime) diff --git a/documentation.md b/documentation.md new file mode 100644 index 00000000..52bf7271 --- /dev/null +++ b/documentation.md @@ -0,0 +1,82 @@ +# Containerization Process Documentation + +## Overview + +This documentation outlines the process of containerizing the web application using Docker. The containerization process involves creating a Docker image that encapsulates the application and its dependencies, making it easy to deploy consistently across different environments. + +## Dockerfile + +The Dockerfile defines the instructions for building the Docker image. Here are the key steps taken in the Dockerfile: + +```Dockerfile +# Use an official Python runtime as a parent image. +FROM python:3.8-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the entire project into the container +COPY . /app + +# Make the entrypoint script executable +RUN chmod +x /app/entrypoint.sh + +# Install system dependencies and ODBC driver +RUN apt-get update && apt-get install -y \ + unixodbc unixodbc-dev odbcinst odbcinst1debian2 libpq-dev gcc && \ + apt-get install -y gnupg && \ + apt-get install -y wget && \ + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ + wget -qO- https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ + apt-get update && \ + ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \ + apt-get purge -y --auto-remove wget && \ + apt-get clean + +# Install pip and setuptools +RUN pip install --upgrade pip setuptools + +# Install Python packages specified in requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt + +# Expose port +EXPOSE 5000 + +# Define Startup Command using entrypoint script +ENTRYPOINT ["/app/entrypoint.sh"] +``` + +## Docker Commands + +### Building the Docker Image + +```bash +docker build -t myflaskapp . +``` + +This command builds a Docker image named `myflaskapp` from the current directory (`.`) containing the Dockerfile and the application files. + +### Running a Container + +```bash +docker run -p 5000:5000 myflaskapp +``` + +This command runs a Docker container based on the `myflaskapp` image, mapping port 5000 from the host to port 5000 in the container. + +### Tagging and Pushing to Docker Hub + +```bash +docker tag myflaskapp username/myflaskapp:latest +docker push username/myflaskapp:latest +``` + +Replace `username` with your Docker Hub username. These commands tag the image and push it to Docker Hub for distribution. + +## Image Information + +- **Image Name:** myflaskapp +- **Tags:** latest +- **Instructions for Use:** Run the container with the `docker run` command, mapping the necessary ports. Make sure to replace environment-specific values if needed. + +This documentation provides a step-by-step guide for containerizing the web application using Docker. It includes the Dockerfile, commands used, and essential information about the Docker image. \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..62e36522 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +# Place any setup or initialization commands here +# For example: +echo "Initializing my application..." + +# Run the main application command +exec python app.py + diff --git a/feature_documentation.md b/feature_documentation.md new file mode 100644 index 00000000..84535a1f --- /dev/null +++ b/feature_documentation.md @@ -0,0 +1,32 @@ +# Feature Documentation: Adding and Reverting the 'delivery_date' Field + +## Introduction +This document outlines the process of adding a 'delivery_date' field to a form in the company's internal application, along with the necessary database changes. Although the feature was initially implemented, it has been subsequently reverted. + +## Feature Overview +The 'delivery_date' feature aimed to enhance the application by capturing delivery date information during form submissions. + +## Implementation Steps + +### 1. Add 'delivery_date' Field to Form +To implement the feature, a new field named 'delivery_date' was added to the relevant form. This allowed users to input the desired delivery date when submitting the form. + +### 2. Update Database Schema +A corresponding column named 'delivery_date' was introduced in the database schema to store the delivery date information associated with each form entry. + +## How It Works +Users could access the form as usual, and the 'delivery_date' field was seamlessly integrated into the submission process. + +## Reversion Process + +### 1. Identified Issues +After implementation, it became apparent that the 'delivery_date' feature presented unforeseen challenges or was deemed unnecessary. + +### 2. Revert Changes +To address these concerns, the changes associated with the 'delivery_date' feature were reverted to restore the application to its previous state. + +## Developer Information +For developers who may need to understand or modify the code related to the 'delivery_date' feature, the relevant code changes can be found in [specific code files or commits]. + +## Conclusion +While the 'delivery_date' feature was briefly introduced to enhance the form, its inclusion posed challenges or was deemed unnecessary, leading to its subsequent reversion. This documentation serves as a record of the implementation and reversion process for future reference. diff --git a/templates/orders.html b/templates/orders.html index 9372e2d0..84b27325 100644 --- a/templates/orders.html +++ b/templates/orders.html @@ -27,6 +27,7 @@

Order List

Product Quantity Order Date Shipping Date + Delivery Date