Python/Flask app for testing infrastructure
-
Displays environment variables
-
Connects to DB instance
-
Stress functions based on: https://github.com/mattixtech/stress
-
install prerequisites
brew install python3 pyenv pyenv-virtualenv virtualenv
-
create virtualenv
virtualenv venv
-
activate virutalenv
. venv/bin/activate
-
verify virtual python version
python --version
-
install pip packages to virutalenv
pip install -r ./requirements.txt
-
run app
python3 ./main.py
-
NOTE: Relies on version tag in
version.py
-
on M1 Mac (requires special 'buildx' invocation)
TAG=`cat version.py | cut -f2 -d= | tr -d \'`; docker buildx build --platform linux/amd64 -t acutchinbitpusher/actest:$TAG .
-
on Linux
TAG=`cat version.py | cut -f2 -d= | tr -d \'`; docker build -f Dockerfile -t acutchinbitpusher/actest:$TAG .
-
set shell environment variables for convenience
export CONTAINER='<container_name>'
-
build the container according to the Dockerfile
docker build -t $CONTAINER $PWD
-
run the container on port 8080
docker run -d -p 8080:80 -t $CONTAINER
-
observe the new image and running container
docker ps -a; echo; docker images
-
curl the container:8080 to test
curl http://localhost:8080
-
stop/delete the image
docker stop $CONTAINER && docker rm $CONTAINER
-
repeatedly stop/delete/rebuild the container and test curl:
-
first time
docker stop $CONTAINER && docker rm $CONTAINER && docker build -t $CONTAINER . && docker run -d -p 8080:80 --name $CONTAINER $CONTAINER && echo "sleeping 5..." && sleep 5 && curl http://localhost:8080/index.html && echo && echo && docker logs $CONTAINER
-
repeatedly thereafter
docker stop $CONTAINER && docker rm $CONTAINER && docker build -t $CONTAINER . && docker run -d -p 8080:80 --name $CONTAINER $CONTAINER && echo "sleeping 5..." && sleep 5 && curl http://localhost:8080/index.html && echo && echo && docker logs $CONTAINER
-
-
DockerHub
TAG=`cat version.py | cut -f2 -d= | tr -d \'`; docker push acutchinbitpusher/actest:$TAG
-
AWS ECR
-
Set shell environment variables for convenience
export CONTAINER='<container_name>'; export ECR_ACCOUNT_ID='<ecr_account_id>'; export ECR_REGION='<ecr_region>'; export TAG=`cat version.py | cut -f2 -d= | tr -d \'`; export ECR_URL="$ECR_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com"
-
Rebuild the image for EC2/ECS hardware platform, if necessary
docker build --platform linux/amd64 -t $CONTAINER $PWD
-
Import AWS creds to shell environment
awsume `<aws_account_name>`
-
Log in to ECR
aws --region $ECR_REGION ecr get-login-password | docker login --username AWS --password-stdin $ECR_URL
- you should see "Login Succeeded"
-
tag the container with the ECR info
docker tag $CONTAINER $ECR_URL/$CONTAINER:latest
-
push image to ECR
docker push $ECR_URL/$CONTAINER
-
-
BITPUSHER CHEF/DOCKER EC2 INSTANCES
chef-client
-
ECS
aws --region $AWS_DEFAULT_REGION ecs update-s ervice --cluster <ecs_cluster_name> --service <ecs_service_name> --force-new-deployment