Skip to content

AWS + Docker + localstack + Buildkite + Spring Boot + Terraform + ReactJS

License

Notifications You must be signed in to change notification settings

create1st/docker-localstack

Repository files navigation

docker-localstack

Docker + localstack + Buildkite

docker network create docker-localstack-network
docker-compose -f docker-compose-localstack.yaml up

eval `ssh-agent`
export TF_CLI_ARGS_apply="-no-color"
export TF_CLI_ARGS_plan="-no-color"
bk run -E SSH_AUTH_SOCK="$SSH_AUTH_SOCK"
bk run .buildkite/pipeline-aws-ops.yaml
bk run .buildkite/pipeline-k8s-ops.yaml
bk run .buildkite/pipeline-aws-ops-development.yaml
buildkite-agent start --spawn 5 --tags "queue=global,queue=infra,queue=dev-aws-ops,queue=dev-k8s-ops,queue=app"
cd app
docker-compose -f docker-compose-integration-tests.yml build 
docker-compose -f docker-compose-integration-tests.yml up localstack-setup postgresql
docker-compose -f docker-compose-integration-tests.yml run integration-test
cd app
docker-compose -f docker-compose-acceptance-tests.yml build 
docker-compose -f docker-compose-acceptance-tests.yml up localstack-setup postgresql
docker-compose -f docker-compose-acceptance-tests.yml run acceptance-test
bk run app/.buildkite/pipeline.yaml
bk run webapp/.buildkite/pipeline.yaml

IntelliJ

cd app
docker-compose -f docker-compose-local.yml build
docker-compose -f docker-compose-local.yml up

Run Web application

docker run -p 80:8080 docker-localstack-webapp:latest

K8s

docker-comdocker -f .buildkite/image/docker-compose.yml build k8s-ci-cd
bk run .buildkite/pipeline-k8s-ci-di-image.yaml

Build

JIB app

cd app
gradle clean build test jib -x integrationTest -x acceptanceTest
docker image rm craftandtechnology/docker-localstack:latest
#docker pull craftandtechnology/docker-localstack:latest
docker-compose up
docker-compose rm -f
docker image rm craftandtechnology/docker-localstack:latest

webapp

cd webapp
docker-compose build

https-proxy sidecar

cd https-proxy
mkdir -p "$(pwd)/nginx/etc/ssl/private"
mkdir -p "$(pwd)/nginx/etc/ssl/certs"
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "$(pwd)/nginx/etc/ssl/private/nginx-selfsigned.key" -out "$(pwd)/nginx/etc/ssl/certs/nginx-selfsigned.crt"
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
docker-compose build
docker push craftandtechnology/https-proxy:latest

Minikube

localstack

minikube start
kubect create -f localstack.pod.k8s.yaml
kubect create -f localstack.service.k8s.yaml
kubectl port-forward $(kubectl get pods | grep "^localstack" | awk {'print $1}') 4566:4566
localstack.init.k8s.sh

postgres

kubect create -f postgres.configmap.k8s.yaml
kubect create -f postgres.pv.k8s.yaml
kubect create -f postgres.pod.k8s.yaml
kubect create -f postgres.service.k8s.yaml

app

kubect create -f app.pod.k8s.yaml
kubect create -f app.service.k8s.yaml
# Port forwarding to check service
kubectl port-forward $(kubectl get pods | grep "docker-localstack" | grep -v "webapp" | awk {'print $1}') 8080:8080
# Check logs
kubectl logs -f -l app=docker-localstack -c docker-localstack

webapp

docker push craftandtechnology/docker-localstack-webapp:latest
kubect create -f webapp.pod.k8s.yaml
kubectl create -f webapp.service.k8s.yaml
# Port forwarding to check service
kubectl port-forward $(kubectl get pods | grep "docker-localstack-webapp" | awk {'print $1}') 8080:8080
# Check logs
kubectl logs -f -l app=docker-localstack-webapp -c docker-localstack-webapp
# Create tunnel for load balancer
minikube tunnel

webapp/web-ui/.env

REACT_APP_AUTH0_DOMAIN=
REACT_APP_AUTH0_CLIENT_ID=
REACT_APP_AUTH0_AUDIENCE=
REACT_APP_AUTH0_SCOPE=read:orders
REACT_APP_REST_ENDPOINT=http://localhost:8080

Running

Self-signed certificate => https://stackoverflow.com/questions/35274659/when-you-use-badidea-or-thisisunsafe-to-bypass-a-chrome-certificate-hsts-err

curl --insecure https://localhost:8443/rest/orders

Buildkite

Docker

export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0

AWS

Rotate password https://docs.aws.amazon.com/secretsmanager/latest/userguide/tutorials_db-rotate.html

ENV

SPRING_PROFILES_ACTIVE=local,acceptance-test-local
JAVA_TOOL_OPTIONS=-Ddrivers.vpcEndpointRegion=us-east-1 -Ddrivers.vpcEndpointUrl=http://localstack:4566