updated eployment script
This commit is contained in:
Regular → Executable
+20
-9
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
REPO_URL="http://owusu:890eccfcea010beb94a0adba246aaf9258330b70@23.29.118.76:3000/owusu/ds-fire-fighter.git"
|
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"
|
BRANCH="main"
|
||||||
PYTHON_VERSION="3.11"
|
PYTHON_VERSION="3.11"
|
||||||
WORKERS=4
|
WORKERS=4
|
||||||
@@ -61,11 +61,22 @@ command_exists() {
|
|||||||
# Function to install Python 3.11
|
# Function to install Python 3.11
|
||||||
install_python() {
|
install_python() {
|
||||||
log "INFO" "Installing Python ${PYTHON_VERSION}..."
|
log "INFO" "Installing Python ${PYTHON_VERSION}..."
|
||||||
sudo apt-get update
|
sudo yum update -y
|
||||||
sudo apt-get install -y software-properties-common
|
sudo yum groupinstall -y "Development Tools"
|
||||||
sudo add-apt-repository -y ppa:deadsnakes/ppa
|
sudo yum install -y openssl-devel bzip2-devel libffi-devel xz-devel
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-venv python${PYTHON_VERSION}-dev
|
# 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
|
# Function to setup git repository
|
||||||
@@ -86,7 +97,7 @@ setup_repo() {
|
|||||||
setup_venv() {
|
setup_venv() {
|
||||||
log "INFO" "Setting up virtual environment..."
|
log "INFO" "Setting up virtual environment..."
|
||||||
if [ ! -d "$APP_DIR/venv" ]; then
|
if [ ! -d "$APP_DIR/venv" ]; then
|
||||||
python${PYTHON_VERSION} -m venv $APP_DIR/venv
|
python3.11 -m venv $APP_DIR/venv
|
||||||
fi
|
fi
|
||||||
source $APP_DIR/venv/bin/activate
|
source $APP_DIR/venv/bin/activate
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
@@ -154,7 +165,7 @@ Description=Fire Fighter Interview API
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=$USER
|
User=ec2-user
|
||||||
WorkingDirectory=$APP_DIR
|
WorkingDirectory=$APP_DIR
|
||||||
Environment="PATH=$APP_DIR/venv/bin"
|
Environment="PATH=$APP_DIR/venv/bin"
|
||||||
Environment="PYTHONPATH=$APP_DIR"
|
Environment="PYTHONPATH=$APP_DIR"
|
||||||
@@ -176,7 +187,7 @@ main() {
|
|||||||
log "INFO" "Starting deployment process..."
|
log "INFO" "Starting deployment process..."
|
||||||
|
|
||||||
# Check and install Python if needed
|
# Check and install Python if needed
|
||||||
if ! command_exists python${PYTHON_VERSION}; then
|
if ! command_exists python3.11; then
|
||||||
install_python
|
install_python
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user