From 2bf5caf80fecc985c040fc3d8444d89db4f412b8 Mon Sep 17 00:00:00 2001 From: abdulhade Date: Tue, 11 Mar 2025 01:07:17 +0300 Subject: [PATCH] Updated the scripts and Dockerfile --- Dockerfile | 18 ++++---- README.md | 10 +++- scripts/manager.sh | 78 +++++++++++++++++++++++++++++++- scripts/{install.sh => setup.sh} | 0 4 files changed, 95 insertions(+), 11 deletions(-) rename scripts/{install.sh => setup.sh} (100%) diff --git a/Dockerfile b/Dockerfile index c7e902e..8459734 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,19 +16,19 @@ WORKDIR /app # && rm -rf /var/lib/apt/lists/* -# Clone the Git repository -RUN apt-get update -RUN apt-get install -y git \ - && git clone https://gitea.abdulhade.com/abdulhade/db-middleware.git . \ - && apt-get remove -y git \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* - +RUN mkdir files/ +COPY files/requirements.txt files/requirements.txt +RUN sleep 5 # Install Python dependencies RUN pip install --no-cache-dir -r files/requirements.txt # Expose port 8080 for the FastAPI application -EXPOSE 8080 +# EXPOSE 8080 + +COPY . . + +RUN rm files/db.sqlite +RUN /usr/local/bin/alembic -c alembic/alembic.ini upgrade head # Command to run the FastAPI application CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] \ No newline at end of file diff --git a/README.md b/README.md index 768b8b3..b843339 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ -# db-middleware +# Capital Index Database Middleware +### This repo contains: + +1. Middleware Source Code +2. Dockerfile +3. Install & Manage Script + +### Getting Started: +Run this command: diff --git a/scripts/manager.sh b/scripts/manager.sh index 79f1bc6..35d7661 100755 --- a/scripts/manager.sh +++ b/scripts/manager.sh @@ -1 +1,77 @@ -docker build -t db-middleware . \ No newline at end of file +#!/bin/bash + +APP_DIR="$HOME/.db-middleware" +CODE_DIR="$HOME/.db-middleware/code" + +install() { + echo "Installing the Middleware." + cd "$CODE_DIR" + + docker build -t db-middleware . + + echo "Installed the Middleware Successfully." +} + +# Function for the "upgrade" command +upgrade() { + echo "Running the 'upgrade' function." + # Add your upgrade logic here +} + +# Function for the "status" command +status() { + echo "Running the 'status' function." + # Add your status-checking logic here +} + +# Function for the "start" command +start() { + echo "Running the 'start' function." + # Add your start logic here +} + +# Function for the "stop" command +stop() { + echo "Running the 'stop' function." + # Add your stop logic here +} + +# Function to display usage instructions +usage() { + echo "Usage: $0 {install|upgrade|status|start|stop}" + exit 1 +} + +# Main script logic +main() { + # Check if an argument is provided + if [[ $# -eq 0 ]]; then + usage + fi + + # Handle the argument + case "$1" in + install) + install + ;; + upgrade) + upgrade + ;; + status) + status + ;; + start) + start + ;; + stop) + stop + ;; + *) + echo "Invalid argument: $1" + usage + ;; + esac +} + +# Run the script with the provided arguments +main "$@" diff --git a/scripts/install.sh b/scripts/setup.sh similarity index 100% rename from scripts/install.sh rename to scripts/setup.sh