Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('/')
Expand Down
17 changes: 17 additions & 0 deletions db.py
Original file line number Diff line number Diff line change
@@ -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)
82 changes: 82 additions & 0 deletions documentation.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

32 changes: 32 additions & 0 deletions feature_documentation.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions templates/orders.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h2 class="tab-title">Order List</h2>
<th>Product Quantity</th>
<th>Order Date</th>
<th>Shipping Date</th>
<th>Delivery Date</th>
</tr>
</thead>
<tbody>
Expand Down