Skip to content

Commit

Permalink
modify appspec and add a docker-compose for dev
Browse files Browse the repository at this point in the history
  • Loading branch information
aryan9600 committed Sep 24, 2021
1 parent b7d808c commit 9a735fd
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Dockerfile
*.log
.env
docker-compose.yml
rust-toolchain
docker-compose.dev.yml
1 change: 1 addition & 0 deletions appspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ os: linux
files:
- source: /
destination: /opt/kv-store
file_exists_behavior: OVERWRITE
hooks:
ApplicationStart:
- location: scripts/deploy.sh
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

services:
web:
build: .
depends_on:
- nats
env_file: .env
ports:
- "8000:${PORT:-8000}"

nats:
image: nats:2.6.0-alpine
ports:
- "4222:4222"
14 changes: 11 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ version: '3'
services:
web:
build: .
ports:
- "8000:${PORT:-8000}"
depends_on:
- nats
env_file: .env
ports:
- 80

nats:
image: nats:2.6.0-alpine
ports:
- "4222:4222"
env_file: .env

lb:
image: dockercloud/haproxy
links:
- web
ports:
- 80:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
26 changes: 13 additions & 13 deletions scripts/deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# !/bin/bash
for container_id in `docker ps --format "table {{.ID}} {{.Names}} {{.CreatedAt}}" | grep web | awk -F " " '{print $1}'`
#!/usr/bin/env bash
container_id=""
for id in `docker ps --format "table {{.ID}} {{.Names}} {{.CreatedAt}}" | grep web | awk -F " " '{print $1}'`
do
container_ids+=($container_id)
container_id="$id"
done
docker-compose up -d --build --no-deps --scale web=2 --no-recreate server
echo "found running web container: $container_id"
echo "scaling web to 2 containers"
docker-compose up -d --build --no-deps --scale web=2 --no-recreate web
sleep 10
for container_id in "${container_ids[@]}"
do
docker kill -s SIGTERM $container_id
done
echo "killing container $container_id"
docker kill -s SIGTERM $container_id
sleep 1
for container_id in "${container_ids[@]}"
do
docker rm -f $container_id
done
echo "removing container $container_id"
docker rm -f $container_id
sleep 1
docker-compose up -d --no-deps --scale web=1 --no-recreate server
echo "scaling back down to one container"
docker-compose up -d --no-deps --scale web=1 --no-recreate web

0 comments on commit 9a735fd

Please sign in to comment.