Skip to content

Commit

Permalink
Merge pull request #42 from cbautista1002/docker_compose_for_test
Browse files Browse the repository at this point in the history
Create prod and test env docker compose yaml files; Update readme
  • Loading branch information
Carlos Bautista committed Mar 26, 2015
2 parents 8803b14 + 17470b5 commit 67869c3
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 43 deletions.
98 changes: 68 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,71 @@ with Alpine Linux. The main application container has a LAMP stack of:
Build status on CircleCI (master branch): [![Circle CI](https://circleci.com/gh/ISEexchange/tacstack/tree/master.svg?style=svg&circle-token=373b7a10221a0403c993da96c45ba15ef225e932)](https://circleci.com/gh/ISEexchange/tacstack/tree/master)


Build and Deploy locally with docker-compose
How to Launch a Production System
-------------

docker-compose will provide a fully functioning MAP system
from scratch. It will build all of the required images and start up
the containers. It will also take care of linking the data and app
containers and will provide ports for you to use. Use this to create
either a test environment or a production environment. To get started,
clone this git repo, then run:
Download this repo so you can use docker-compose files:

git clone https://github.com/ISEexchange/tacstack.git
cd tacstack

You first need to get the container images from quay.io (the
repo in the cloud where we store our build images):

docker-compose -f docker-compose-common.yml pull

Now start up the containers for a production system. This
basically means that the ports will be pre-selected:

docker-compose -f docker-compose-prod.yml up -d


How to Launch a Test Environment
-------------

Pretty much the same as above except the docker-compose
up command will be different:

docker-compose -f docker-compose-testenv.yml -p mytestenv up -d

Output:

docker-compose up -d
Creating mytestenv_mysqldatavoltestenv_1...
Creating mytestenv_ftpdatavoltestenv_1...
Creating mytestenv_mapapptestenv_1...
Creating mytestenv_ftpapptestenv_1...

The `-d` will start the applications in the background.
The `-p` is what will allow you to have your own set
of containers, independent from any other.

The ports for the internal applications will be randomly

docker-compose Notes
-------------

docker-compose will provide a fully functioning system of containers
from scratch. It will pull all of the required images and start up
the containers. It will also take care of linking the data and app
containers and will provide ports for you to use. Use docker-compose
to create either a test environment or a production environment.

The `-d` in the `docker-compose up` command will start the
containers/services in the background.

The ports for the test environment containers will be randomly
selected. To find them, run:

docker-compose ps
docker-compose -f docker-compose-testenv.yml ps

The ports will be listed under the mapapp container.
Or

docker-compose -f docker-compose-testenv.yml -p mytestenv port mapapptestenv 22

There are four services in this system that docker-compose will bring up:

mapapp
ftpapp
mysqldatavol
ftpdatavol
mapapp[prod|testenv]
ftpapp[prod|testenv]
mysqldatavol[prod|testenv]
ftpdatavol[prod|testenv]

For more information on docker-compose:
https://docs.docker.com/compose/
Expand All @@ -49,11 +87,10 @@ Build on CircleCI

Open a pull request on Github.
This triggers a build in CircleCI.
At the moment, this will only build the main docker application.
docker-compose integration with CircleCI coming soon.
Dockerfiles will be built and completed docker images will be pushed to quay.io.


Pull an already-built image
Pull an Already-Built Image
---------------------------

If you want the latest build of master branch:
Expand All @@ -72,7 +109,7 @@ If you want the version from your pull request:
docker pull quay.io/iseexchange/tacstack:${handle}_pull_${number}


Build locally with docker
Build Locally With Docker
-------------

To build the main application container, clone this git
Expand All @@ -87,21 +124,20 @@ Manual Deployment
Follow these instructions if you are not using docker-compose.
For a live TAC application, run:

```
docker run -d -p 2222:22 -p 80:80 quay.io/iseexchange/tacstack
```
docker run -d quay.io/iseexchange/tacstack_ftpdata:latest --name FTPData
docker run -d jumanjiman/dropbox:latest
docker run -d quay.io/iseexchange/tacstack_mysqldata:latest --name MySQLData
docker run -d -p 18922:22 -p 80:80 -p 18906:3306 -p 18900:18900 -p 18901:18901 --name MAPApp --volumes-from MySQLData --volumes-from FTPData quay.io/iseexchange/tacstack

For an individual test environment, run:

```
CID=$(docker run -d -P quay.io/iseexchange/tacstack)
CID=$(docker run -d -P quay.io/iseexchange/tacstack)

# Find the port on which sshd is running.
docker port $CID 22
# Find the port on which sshd is running.
docker port $CID 22

# Find the port on which apache is running.
docker port $CID 80
```
# Find the port on which apache is running.
docker port $CID 80


Troubleshooting
Expand All @@ -112,8 +148,10 @@ Troubleshooting
```bash
# Commands for docker-compose:
# List active and exited containers.
docker-compose -f docker-compose-testenv.yml -p mytestenv ps
docker-compose ps
# Follow logs from a container.
docker-compose -f docker-compose-testenv.yml -p mytestenv logs
docker-compose logs <service-name>

# Commands for docker:
Expand Down
13 changes: 0 additions & 13 deletions docker-compose.yml → docker-compose-common.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
mapapp:
image: quay.io/iseexchange/tacstack:latest
command: supervisord -n
ports:
- "18922:22"
- "80:80"
- "18906:3306"
- "18900:18900"
- "18901:18901"
volumes_from:
- mysqldatavol
- ftpdatavol

ftpapp:
image: jumanjiman/dropbox
ports:
- "21:21"
volumes_from:
- ftpdatavol

mysqldatavol:
image: quay.io/iseexchange/tacstack_mysqldata:latest
Expand Down
32 changes: 32 additions & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
mapappprod:
extends:
file: docker-compose-common.yml
service: mapapp
ports:
- "18922:22"
- "80:80"
- "18906:3306"
- "18900:18900"
- "18901:18901"
volumes_from:
- mysqldatavolprod
- ftpdatavolprod

ftpappprod:
extends:
file: docker-compose-common.yml
service: ftpapp
ports:
- "21:21"
volumes_from:
- ftpdatavolprod

mysqldatavolprod:
extends:
file: docker-compose-common.yml
service: mysqldatavol

ftpdatavolprod:
extends:
file: docker-compose-common.yml
service: ftpdatavol
32 changes: 32 additions & 0 deletions docker-compose-testenv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
mapapptestenv:
extends:
file: docker-compose-common.yml
service: mapapp
ports:
- "22"
- "80"
- "3306"
- "18900"
- "18901"
volumes_from:
- mysqldatavoltestenv
- ftpdatavoltestenv

ftpapptestenv:
extends:
file: docker-compose-common.yml
service: ftpapp
ports:
- "21"
volumes_from:
- ftpdatavoltestenv

mysqldatavoltestenv:
extends:
file: docker-compose-common.yml
service: mysqldatavol

ftpdatavoltestenv:
extends:
file: docker-compose-common.yml
service: ftpdatavol

0 comments on commit 67869c3

Please sign in to comment.