Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker/docker-compose.infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.0
container_name: techfork-elasticsearch
hostname: techfork-elasticsearch
restart: always
ports:
- "9200:9200"
- "9300:9300"
environment:
- node.name=techfork-elasticsearch
- discovery.type=single-node
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms8g -Xmx8g"
Expand Down
16 changes: 8 additions & 8 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ DEPLOY_DIR="$(cd "$(dirname "$0")/.." && pwd)"
STATE_FILE="${DEPLOY_DIR}/.active-color"
LOCK_DIR="${DEPLOY_DIR}/.deploy.lock"
DOCKER_DIR="${DEPLOY_DIR}/docker"
COMPOSE_INFRA="${DOCKER_DIR}/docker-compose.infra.yml"
COMPOSE_BLUE="${DOCKER_DIR}/docker-compose.blue.yml"
COMPOSE_GREEN="${DOCKER_DIR}/docker-compose.green.yml"
COMPOSE_INFRA="-p techfork-infra -f ${DOCKER_DIR}/docker-compose.infra.yml"
COMPOSE_BLUE="-p techfork-blue -f ${DOCKER_DIR}/docker-compose.blue.yml"
COMPOSE_GREEN="-p techfork-green -f ${DOCKER_DIR}/docker-compose.green.yml"
UPSTREAM_CONF="${DOCKER_DIR}/nginx/conf.d/upstream.conf"

HEALTH_CHECK_RETRIES=30
Expand Down Expand Up @@ -110,7 +110,7 @@ docker network create techfork-network 2>/dev/null || true

# Step 2: Start infrastructure
log "Starting infrastructure services..."
docker compose -f "$COMPOSE_INFRA" up -d
docker compose $COMPOSE_INFRA up -d

log "Waiting for Elasticsearch to be healthy..."
timeout 120 bash -c 'until docker exec techfork-elasticsearch curl -sf http://localhost:9200/_cluster/health > /dev/null 2>&1; do sleep 5; done' || {
Expand All @@ -132,18 +132,18 @@ TARGET_CONTAINER=$(get_container_name "$TARGET_COLOR")

# Step 4: Pull new image
log "Pulling latest image for ${TARGET_COLOR}..."
docker compose -f "$TARGET_COMPOSE" pull
docker compose $TARGET_COMPOSE pull

# Step 5: Start target container
log "Starting ${TARGET_COLOR} container..."
docker compose -f "$TARGET_COMPOSE" up -d
docker compose $TARGET_COMPOSE up -d

# Step 6: Health check
if health_check "$TARGET_CONTAINER"; then
log "Target container ${TARGET_CONTAINER} is healthy"
else
log "ROLLBACK: Stopping failed ${TARGET_COLOR} container..."
docker compose -f "$TARGET_COMPOSE" down
docker compose $TARGET_COMPOSE down
log "Rollback complete. Active deployment unchanged: ${ACTIVE_COLOR:-none}"
exit 1
fi
Expand All @@ -158,7 +158,7 @@ sleep 10
if [ -n "$ACTIVE_COLOR" ]; then
OLD_COMPOSE=$(get_compose_file "$ACTIVE_COLOR")
log "Stopping old ${ACTIVE_COLOR} container..."
docker compose -f "$OLD_COMPOSE" down
docker compose $OLD_COMPOSE down
fi

# Step 10: Save active color
Expand Down
Loading