From 17470b589b95c94ca7b00c028ae64437e9453b62 Mon Sep 17 00:00:00 2001 From: Carlos Bautista Date: Thu, 26 Mar 2015 18:09:22 +0000 Subject: [PATCH] Create prod and test env docker compose yaml files; Update readme --- README.md | 98 +++++++++++++------ ...r-compose.yml => docker-compose-common.yml | 13 --- docker-compose-prod.yml | 32 ++++++ docker-compose-testenv.yml | 32 ++++++ 4 files changed, 132 insertions(+), 43 deletions(-) rename docker-compose.yml => docker-compose-common.yml (54%) create mode 100644 docker-compose-prod.yml create mode 100644 docker-compose-testenv.yml diff --git a/README.md b/README.md index a9db04b..ddc2114 100644 --- a/README.md +++ b/README.md @@ -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/ @@ -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: @@ -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 @@ -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 @@ -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 # Commands for docker: diff --git a/docker-compose.yml b/docker-compose-common.yml similarity index 54% rename from docker-compose.yml rename to docker-compose-common.yml index 5d79a63..ebb8d5f 100644 --- a/docker-compose.yml +++ b/docker-compose-common.yml @@ -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 diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml new file mode 100644 index 0000000..f3cfa2e --- /dev/null +++ b/docker-compose-prod.yml @@ -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 diff --git a/docker-compose-testenv.yml b/docker-compose-testenv.yml new file mode 100644 index 0000000..3a9e114 --- /dev/null +++ b/docker-compose-testenv.yml @@ -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