Skip to content

Commit 70cfc74

Browse files
committed
Add Docker Compose configuration and enhance production script
1 parent adfa50c commit 70cfc74

File tree

2 files changed

+66
-17
lines changed

2 files changed

+66
-17
lines changed

generate/docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3.8'
2+
3+
services:
4+
brainrot:
5+
image: 604711046876.dkr.ecr.us-east-1.amazonaws.com/brainrot:latest
6+
container_name: brainrot-container
7+
ports:
8+
- "3000:3000"
9+
volumes:
10+
- ./shared_data:/app/brainrot/shared_data
11+
environment:
12+
- MODE=production
13+
- RVC_SERVICE_URL=http://rvc:5555
14+
depends_on:
15+
- rvc
16+
17+
rvc:
18+
image: 604711046876.dkr.ecr.us-east-1.amazonaws.com/rvc:latest
19+
container_name: rvc-container
20+
ports:
21+
- "5555:5555"
22+
volumes:
23+
- ./shared_data:/app/shared_data
24+
environment:
25+
- MODE=production
26+
- SHARED_DIR=/app/shared_data
27+
deploy:
28+
resources:
29+
reservations:
30+
devices:
31+
- driver: nvidia
32+
count: all
33+
capabilities: [gpu]

generate/scripts/run_prod.sh

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/bin/bash
22
set -e
33

4+
if [ -f "$(dirname "$0")/../.env" ]; then
5+
set -a
6+
source "$(dirname "$0")/../.env"
7+
set +a
8+
else
9+
echo "ERROR: .env file not found"
10+
exit 1
11+
fi
12+
413
if [ -z "$AWS_ACCOUNT_ID" ]; then
514
echo "ERROR: AWS_ACCOUNT_ID environment variable is not set"
615
echo "Please run: export AWS_ACCOUNT_ID=your_aws_account_id"
@@ -17,21 +26,32 @@ ECR_URL="${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com"
1726
BRAINROT_IMAGE="$ECR_URL/brainrot:latest"
1827
RVC_IMAGE="$ECR_URL/rvc:latest"
1928

20-
echo "ECR URL: $ECR_URL"
21-
echo "Brainrot Image: $BRAINROT_IMAGE"
22-
echo "RVC Image: $RVC_IMAGE"
29+
echo "Checking local images against ECR..."
2330

24-
echo "Logging into ECR..."
25-
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin "$ECR_URL"
31+
check_and_pull_image() {
32+
local image_name=$1
33+
local local_digest
34+
local remote_digest
35+
36+
echo "Checking $image_name..."
37+
38+
local_digest=$(docker images --no-trunc --quiet "$image_name" 2>/dev/null)
39+
40+
if aws ecr describe-images --repository-name=$(echo $image_name | cut -d'/' -f2) --image-ids imageTag=latest --region us-east-1 &>/dev/null; then
41+
echo "Found image in ECR, checking if update needed..."
42+
if docker pull "$image_name" &>/dev/null; then
43+
echo "Successfully pulled updated image from ECR"
44+
else
45+
echo "Failed to pull from ECR, using local image"
46+
fi
47+
else
48+
echo "Image not found in ECR or access denied, using local image"
49+
fi
50+
}
2651

27-
echo "Stopping any existing containers..."
28-
docker-compose down || true
29-
30-
echo "Creating shared directories..."
31-
mkdir -p shared_data
32-
33-
echo "Setting permissions on shared_data directory..."
34-
chmod -R 777 shared_data
52+
# Check both images
53+
check_and_pull_image "$BRAINROT_IMAGE"
54+
check_and_pull_image "$RVC_IMAGE"
3555

3656
echo "Creating docker-compose.yml file..."
3757
cat > docker-compose.yml << EOL
@@ -78,10 +98,6 @@ else
7898
echo "WARNING: NVIDIA GPU not detected. RVC service may not work properly without GPU acceleration."
7999
fi
80100

81-
echo "Pulling latest images from ECR..."
82-
docker pull "$BRAINROT_IMAGE"
83-
docker pull "$RVC_IMAGE"
84-
85101
echo "Starting containers with docker-compose..."
86102
docker-compose up -d
87103

0 commit comments

Comments
 (0)