From 579dab8d0afd623b7dcf236bfb49164f9654e293 Mon Sep 17 00:00:00 2001 From: Josh Flatt Date: Sat, 22 Nov 2025 17:21:39 -0600 Subject: [PATCH] added scripts and docker info --- .dockerignore | 0 Dockerfile | 8 ++++++++ docker-compose.yml | 13 +++++++++++++ requirements.txt | 6 ++++++ scripts/clear_logs.sh | 21 +++++++++++++++++++++ scripts/deploy.sh | 4 ++++ scripts/setup_env.sh | 29 +++++++++++++++++++++++++++++ 7 files changed, 81 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 requirements.txt create mode 100644 scripts/clear_logs.sh create mode 100644 scripts/deploy.sh create mode 100644 scripts/setup_env.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb67ee5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# syntax=docker/dockerfile:1 +FROM python:3 +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 +WORKDIR /code +COPY requirements.txt /code/ +RUN pip install -r requirements.txt +COPY . /code/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e1fc652 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.8' + +services: + web: + build: . + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - ./app/:/usr/src/app/ + restart: unless-stopped + ports: + - 8060:8000 + # env_file: + # - ./.venv diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0990fe5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +django +black +psycopg +pandas +django-crispy-forms +crispy-bootstrap4 \ No newline at end of file diff --git a/scripts/clear_logs.sh b/scripts/clear_logs.sh new file mode 100644 index 0000000..7818d5b --- /dev/null +++ b/scripts/clear_logs.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Define the log directory path +LOG_DIR="./resources/logs/" + +# Check if the directory exists +if [ -d "$LOG_DIR" ]; then + # If it exists, check if there are any .log files in it + if ls "$LOG_DIR"*.log 1> /dev/null 2>&1; then + # If there are log files, remove them + rm "$LOG_DIR"*.log + echo "Log files removed from $LOG_DIR." + else + # If no log files are found + echo "No log files found in $LOG_DIR." + fi +else + # If the directory does not exist, create it + mkdir "$LOG_DIR" + echo "Directory $LOG_DIR created." +fi diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..006c1ed --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,4 @@ +docker stop django_web_web_1 +docker rm django_web_web_1 +docker-compose build --no-cache +docker-compose up -d diff --git a/scripts/setup_env.sh b/scripts/setup_env.sh new file mode 100644 index 0000000..574cc59 --- /dev/null +++ b/scripts/setup_env.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status. +set -e + +# Create the virtual environment in the current directory +echo "Checking to see if virtual environment exists..." +if [ -d .venv ]; then + # echo "Virtual environment already exists. Please delete it before running this script." + # exit 1 + echo "Virtual environment already exists. Skipping creation." +else + echo "Virtual environment does not exist. Creating..." + python3.12 -m venv .venv + echo "Virtual environment created." +fi +# python -m venv .venv + +# Activate the virtual environment +source .venv/bin/activate + +# Install the required packages from the requirements.txt file +pip install -r requirements.txt + +# Upgrade pip +pip install --upgrade pip + +# Print a success message +echo "Virtual environment created and requirements installed successfully."