Merge pull request #2 from talatops/juno-untested
fix: dedicated pre-build image pipeline
This commit is contained in:
commit
1d1aec6c5d
8
.github/workflows/deploy-ec2.yml
vendored
8
.github/workflows/deploy-ec2.yml
vendored
@ -85,7 +85,7 @@ jobs:
|
||||
- name: Copy deployment files to server
|
||||
run: |
|
||||
# Copy docker-compose (app + Postgres), and .env
|
||||
scp -i ssh_key.pem -o StrictHostKeyChecking=no docker-compose.yml ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:${{ env.REMOTE_DIR }}/docker-compose.yml
|
||||
scp -i ssh_key.pem -o StrictHostKeyChecking=no docker-compose.ec2.yml ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:${{ env.REMOTE_DIR }}/docker-compose.ec2.yml
|
||||
scp -i ssh_key.pem -o StrictHostKeyChecking=no .env ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:${{ env.REMOTE_DIR }}/.env
|
||||
|
||||
# Copy application image tar
|
||||
@ -123,14 +123,14 @@ jobs:
|
||||
|
||||
# Rolling update with docker compose (app + Postgres)
|
||||
echo "=== ROLLING UPDATE (docker compose up -d) ==="
|
||||
if ! docker compose -f docker-compose.yml --env-file .env up -d --no-build --remove-orphans; then
|
||||
if ! docker compose -f docker-compose.ec2.yml --env-file .env up -d --remove-orphans; then
|
||||
echo "ERROR: Deployment failed"
|
||||
docker compose -f docker-compose.yml down || true
|
||||
docker compose -f docker-compose.ec2.yml down || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Deployment successful! Current services:"
|
||||
docker compose -f docker-compose.yml --env-file .env ps
|
||||
docker compose -f docker-compose.ec2.yml --env-file .env ps
|
||||
|
||||
# Final cleanup (preserve volumes; prune dangling images only)
|
||||
docker system prune -f --volumes=false || true
|
||||
|
||||
49
docker-compose.ec2.yml
Normal file
49
docker-compose.ec2.yml
Normal file
@ -0,0 +1,49 @@
|
||||
services:
|
||||
db:
|
||||
# Use a Postgres image with pgvector preinstalled so we can enable the `vector` extension
|
||||
image: pgvector/pgvector:pg17
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-dropshipping}
|
||||
ports:
|
||||
- "5444:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
# Ensure the pgvector extension is created on first database init
|
||||
- ./prisma/init-pgvector.sql:/docker-entrypoint-initdb.d/init-pgvector.sql:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
app:
|
||||
# IMPORTANT: EC2 deploy copies only the compose file + env + image tar.
|
||||
# Do not include `build:` here; otherwise Compose will look for a Dockerfile on EC2.
|
||||
image: ${IMAGE_NAME:-junohub-app}:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "3000:3000"
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
# Override DATABASE_URL to use internal docker network hostname
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-password}@db:5432/${POSTGRES_DB:-dropshipping}?schema=public
|
||||
NODE_ENV: production
|
||||
volumes:
|
||||
- ./public/uploads/supplier-products:/app/public/uploads/supplier-products
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/api/health', (r) => { process.exit(r.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user