Microservices support
Squash offers multiple ways to deploy applications based on a microservices architecture.
Once you decide what integration method to use (YAML file, Docker or Kubernetes) you can then have Squash to automatically create deployments for each branch of code and integrate with Pull/Merge Requests.
YAML file
For apps without Docker you can define multiple applications and services within the Squash YAML file. Then use the subdomain port-mapping to associate a microservice endpoint with a Squash deployment's subdomain for easy communication between apps.
Here is a sample .squash.yml file showing how it works, this example assumes a repository with no Dockerfiles or docker-compose files.
- In this example we have one web application defined in the "CRM" deployment.
- An API endpoint supplying customer information to the CRM app.
- The "dockerimage" field on both deployments defines the base OS image to be used. You can use any OS image available within the Docker registry or private docker images as well.
- Even though this repository doesn't use Docker, Squash still creates Docker containers behind the scenes. The deployment mentioned below will have two containers running in the host VM. You can easily access such containers by SSH.
deployments:
API:
dockerimage:
# This is the base OS image we want to use for this app
ubuntu:14.04
vm_size:
1GB
build_steps:
# This is where we install all the essential packages needed
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get install -y
software-properties-common
- DEBIAN_FRONTEND=noninteractive add-apt-repository
ppa:ubuntugis/ubuntugis-unstable
- DEBIAN_FRONTEND=noninteractive apt-get install -y
python python-dev python3.5 python3.5-dev python-pip
python-virtualenv libssl-dev libpq-dev git ssh
build-essential libfontconfig1 libfontconfig1-dev
locales gcc postgresql postgis postgresql-contrib
postgresql-9.3-postgis-2.1 sudo supervisor
- COPY . /code
- cd /code
- bash ./create_venv.sh
launch_steps:
# This is where we run the services and our app
- service postgresql start
- sleep 90
- cd /code
- /code/venv/bin/python /code/manage.py migrate
- /code/venv/bin/python /code/manage.py runserver 0.0.0.0:3000
subdomain_port_mapping:
# this will associate the "api" subdomain with port 3000 running
# in this specific container
- api:3000
port_forwarding:
# Squash by default expects an HTTP service running on port 80.
# For this example the HTTP service is listening to port 3000.
80:3000
CRM:
dockerimage: python:latest
build_steps:
- apt-get update && apt-get install -y libssl-dev libpq-dev git
build-essential libfontconfig1 libfontconfig1-dev curl
- apt install -y nodejs
- pip install setuptools pip --upgrade --force-reinstall
- cd /code
- pip install /code
- python manage.py migrate
launch_steps:
- cd /myproject/mysite
- python manage.py runserver 0.0.0.0:80
environment:
# You may also define environment variables in this section.
# Then add these variables within the run_options command to set
# them inside the docker container.
- SERVICE_TYPE=CRM
ready_wait:
# This will tell Squash to wait up to 50 min (3000 seconds) for a
# success response from the app. The count down only starts after
# the build process is finished.
3000
vm_size:
2GB
run_options: --env SERVICE_TYPE=${SERVICE_TYPE}
Docker-compose
Squash has native support for applications based on docker-compose.
Kubernetes
Click here for more information on using Kubernetes to deploy your apps.