Commit 724e57fd authored by Aryan Noshirvani's avatar Aryan Noshirvani

Add Dockerfile, docker-compose.yml, and .gitlab-ci.yml for CI/CD

parent c676e123
Pipeline #960 failed with stages
in 16 seconds
stages:
- test
- deploy
variables:
PYTHON_VERSION: "3.10"
test_api:
stage: test
image: python:3.10-slim
before_script:
- apt-get update && apt-get install -y ffmpeg git build-essential
- pip install --no-cache-dir -r requirements.txt pytest
script:
- pytest tests/
only:
- main
- merge_requests
deploy_prod:
stage: deploy
image: alpine:latest
before_script:
- apk add --no-cache openssh-client bash
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
script:
- echo "Deploying to production server..."
# Connect via SSH to production runner or jump host
- ssh -p ${PROD_SSH_PORT:-22} root@${PROD_SERVER_IP:-216.126.237.62} "cd /root/antigrav-stax-audio && git pull origin main && docker-compose up -d --build || (pkill -f uvicorn || true; source venv/bin/activate && nohup uvicorn src.api.main:app --host 0.0.0.0 --port 8000 > api.log 2>&1 &)"
only:
- main
FROM python:3.10-slim
# Install system dependencies including ffmpeg for audio processing
RUN apt-get update && apt-get install -y \
ffmpeg \
git \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "8000"]
version: '3.8'
services:
stax-api:
build: .
container_name: stax_backend_api
restart: always
ports:
- "80:8000"
environment:
- HTTP_PROXY=${HTTP_PROXY:-}
- HTTPS_PROXY=${HTTPS_PROXY:-}
- NO_PROXY=localhost,127.0.0.1
volumes:
- ./downloads:/app/downloads
- ./temp:/app/temp
- ./stax.db:/app/stax.db
env_file:
- .env
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment