11#! /bin/bash
2- # Deployment script for Ubuntu Deep Learning AMI instances with Pixi and systemd service
2+ # Deployment script for Ubuntu Deep Learning AMI instances with UV and systemd service
33
44set -e
55
@@ -31,17 +31,17 @@ sudo apt-get update
3131sudo apt-get upgrade -y
3232
3333echo " Installing system dependencies..."
34- sudo apt-get install -y curl
34+ sudo apt-get install -y curl python3.12 python3.12-venv
3535
36- echo " Installing Pixi ..."
37- if command -v pixi & > /dev/null; then
38- echo " Pixi already installed, skipping..."
36+ echo " Installing UV ..."
37+ if command -v uv & > /dev/null; then
38+ echo " UV already installed, skipping..."
3939else
40- curl -fsSL https://pixi .sh/install.sh | sh
41- # Add pixi to PATH for current session
42- export PATH=" $HOME /.pixi /bin:$PATH "
40+ curl -LsSf https://astral .sh/uv /install.sh | sh
41+ # Add uv to PATH for current session
42+ export PATH=" $HOME /.local /bin:$PATH "
4343 # Add to bashrc for future sessions
44- echo ' export PATH="$HOME/.pixi /bin:$PATH"' >> ~ /.bashrc
44+ echo ' export PATH="$HOME/.local /bin:$PATH"' >> ~ /.bashrc
4545fi
4646
4747echo " Cloning repository..."
5757 cd ftw-inference-api
5858fi
5959
60- echo " Installing Pixi environment ..."
61- # Ensure pixi is in PATH for this command
62- export PATH=" $HOME /.pixi /bin:$PATH "
63- pixi install
60+ echo " Installing Python dependencies with UV ..."
61+ # Ensure uv is in PATH for this command
62+ export PATH=" $HOME /.local /bin:$PATH "
63+ uv sync
6464
6565echo " Creating data directories..."
6666mkdir -p server/data/uploads server/data/results server/logs
@@ -91,16 +91,8 @@ APP_DIR="$(pwd)"
9191USER=" $( whoami) "
9292HOME_DIR=" $( eval echo ~ $USER ) "
9393
94- # Conditionally build the ExecStart command based on the GPU configuration.
95- # We check the final destination of the production.env file.
96- BASE_EXEC_START=" ${HOME_DIR} /.pixi/bin/pixi run --environment production python run.py --host 0.0.0.0 --port 8000"
97- EXEC_START_CMD=$BASE_EXEC_START
98-
99- if grep -q " PROCESSING__GPU=null" /etc/ftw-inference-api/production.env; then
100- echo " GPU is disabled. Applying CONDA_OVERRIDE_GLIBC to the service."
101- # Prepend the environment variable directly to the command.
102- EXEC_START_CMD=" CONDA_OVERRIDE_GLIBC=2.17 ${BASE_EXEC_START} "
103- fi
94+ # Build the ExecStart command using UV
95+ BASE_EXEC_START=" ${HOME_DIR} /.local/bin/uv run python run.py --host 0.0.0.0 --port 8000"
10496
10597sudo tee /etc/systemd/system/ftw-inference-api.service > /dev/null << EOF
10698[Unit]
@@ -113,10 +105,9 @@ User=${USER}
113105Group=${USER}
114106WorkingDirectory=${APP_DIR} /server
115107# Set a reliable PATH for the service environment.
116- Environment="PATH=${HOME_DIR} /.pixi /bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
108+ Environment="PATH=${HOME_DIR} /.local /bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
117109EnvironmentFile=/etc/ftw-inference-api/production.env
118- # Use /bin/sh -c to correctly process the command string with the conditional variable.
119- ExecStart=/bin/sh -c "${EXEC_START_CMD} "
110+ ExecStart=${BASE_EXEC_START}
120111Restart=always
121112RestartSec=10
122113StandardOutput=journal
0 commit comments