diff --git a/server_deploy.sh b/server_deploy.sh old mode 100644 new mode 100755 index 0bb1fe8..eacbbaa --- a/server_deploy.sh +++ b/server_deploy.sh @@ -2,7 +2,7 @@ # Configuration REPO_URL="http://owusu:890eccfcea010beb94a0adba246aaf9258330b70@23.29.118.76:3000/owusu/ds-fire-fighter.git" -APP_DIR="/home/owusu/ds-fire-fighter" +APP_DIR="/home/ec2-user/ds-fire-fighter" BRANCH="main" PYTHON_VERSION="3.11" WORKERS=4 @@ -61,11 +61,22 @@ command_exists() { # Function to install Python 3.11 install_python() { log "INFO" "Installing Python ${PYTHON_VERSION}..." - sudo apt-get update - sudo apt-get install -y software-properties-common - sudo add-apt-repository -y ppa:deadsnakes/ppa - sudo apt-get update - sudo apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-venv python${PYTHON_VERSION}-dev + sudo yum update -y + sudo yum groupinstall -y "Development Tools" + sudo yum install -y openssl-devel bzip2-devel libffi-devel xz-devel + + # Install Python 3.11 from source + cd /tmp + wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz + tar xzf Python-3.11.0.tgz + cd Python-3.11.0 + ./configure --enable-optimizations + make -j $(nproc) + sudo make altinstall + + # Create symlink for python3.11 + sudo ln -sf /usr/local/bin/python3.11 /usr/bin/python3.11 + sudo ln -sf /usr/local/bin/pip3.11 /usr/bin/pip3.11 } # Function to setup git repository @@ -86,7 +97,7 @@ setup_repo() { setup_venv() { log "INFO" "Setting up virtual environment..." if [ ! -d "$APP_DIR/venv" ]; then - python${PYTHON_VERSION} -m venv $APP_DIR/venv + python3.11 -m venv $APP_DIR/venv fi source $APP_DIR/venv/bin/activate pip install --upgrade pip @@ -154,7 +165,7 @@ Description=Fire Fighter Interview API After=network.target [Service] -User=$USER +User=ec2-user WorkingDirectory=$APP_DIR Environment="PATH=$APP_DIR/venv/bin" Environment="PYTHONPATH=$APP_DIR" @@ -176,7 +187,7 @@ main() { log "INFO" "Starting deployment process..." # Check and install Python if needed - if ! command_exists python${PYTHON_VERSION}; then + if ! command_exists python3.11; then install_python fi