diff --git a/.github/workflows/deploy.sepolia.yml b/.github/workflows/deploy.sepolia.yml new file mode 100644 index 0000000..5de28a9 --- /dev/null +++ b/.github/workflows/deploy.sepolia.yml @@ -0,0 +1,36 @@ +name: Deploy to Remote Server + +on: + push: + branches: + - sepolia-db + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: SSH into Remote Server and Deploy Changes + uses: appleboy/ssh-action@v1.1.0 + with: + host: ec2-3-87-142-202.compute-1.amazonaws.com + username: ubuntu + key: ${{ secrets.SSH_PRIVATE_KEY }} + passphrase: ${{ secrets.SSH_PASSPHRASE }} + port: 22 + script: | + # Navigate to the project directory + cd ~/fossil-headers-db + + # Pull the latest changes from the main branch + git fetch origin main + git reset --hard origin/main + + # Ensure Docker and Docker Compose are installed + docker --version || { echo "Docker not found"; exit 1; } + docker-compose --version || { echo "Docker Compose not found"; exit 1; } + + # Build and run the Docker Compose services for Sepolia + docker-compose -f docker-compose.sepolia.yml down + docker-compose -f docker-compose.sepolia.yml build --no-cache + docker-compose -f docker-compose.sepolia.yml up -d diff --git a/docker-compose.sepolia.yml b/docker-compose.sepolia.yml new file mode 100644 index 0000000..01b181e --- /dev/null +++ b/docker-compose.sepolia.yml @@ -0,0 +1,45 @@ +version: '3.8' + +services: + update: + build: + dockerfile: Dockerfile.update + context: . + ports: + - "8081:8080" + environment: + - DB_CONNECTION_STRING=${SEPOLIA_DB_STRING} + - NODE_CONNECTION_STRING=${SEPOLIA_NODE_STRING} + - ROUTER_ENDPOINT=${SEPOLIA_ROUTER_ENDPOINT} + - RUST_LOG=info + depends_on: + db: + condition: service_healthy + + fix: + build: + dockerfile: Dockerfile.fix + context: . + environment: + - DB_CONNECTION_STRING=${SEPOLIA_DB_STRING} + - NODE_CONNECTION_STRING=${SEPOLIA_NODE_STRING} + - ROUTER_ENDPOINT=${SEPOLIA_ROUTER_ENDPOINT} + - RUST_LOG=info + - INTERVAL=${FIX_INTERVAL:-300} + depends_on: + db: + condition: service_healthy + + db: + image: postgres:16-alpine + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${SEPOLIA_POSTGRES_DB} + ports: + - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"] + interval: 5s + timeout: 5s + retries: 5