Skip to content
Example Docker Compose app
JavaScript C# CSS HTML Java Python Other
Branch: master
Clone or download
Pull request Compare This branch is 6 commits ahead, 75 commits behind dockersamples:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
result
vote
worker
.gitignore
LICENSE
MAINTAINERS
README.md
architecture.png
codefresh.yml
docker-compose-javaworker.yml
docker-compose-simple.yml
docker-compose.yml
docker-stack.yml
dockercloud.yml

README.md

Example Voting App

Getting started

Download Docker. If you are on Mac or Windows, Docker Compose will be automatically installed. On Linux, make sure you have the latest version of Compose.

Run in this directory:

docker-compose up

The app will be running at http://localhost:5000, and the results will be at http://localhost:5001.

Alternately, if you want to run it on a Docker Swarm, first make sure you have a swarm. If you don't, run:

docker swarm init

Once you have your swarm, in this directory run:

docker stack deploy --compose-file docker-stack.yml vote

Architecture

Architecture diagram

  • A Python webapp which lets you vote between two options
  • A Redis queue which collects new votes
  • A .NET worker which consumes votes and stores them in…
  • A Postgres database backed by a Docker volume
  • A Node.js webapp which shows the results of the voting in real time

Note

The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.

Deploy to Remote Swarm

Codefresh Docker CI/CD service is able to deply the voting application to specified remote swarm cluster.

Add following step to your codefresh.yml

version: '1.0'

steps:

...

  deploy_to_swarm:
    image: codefresh/remote-docker
    working_directory: ${{main_clone}}
    commands:
      - rdocker ${{RDOCKER_HOST}} docker stack deploy --compose-file docker-stack.yml ${{STACK_NAME}}
    environment:
      - SSH_KEY=${{SSH_KEY}}
    when:
      branch:
        only:
          - master

Where:

  • RDOCKER_HOST - remote Docker swarm master machine, accessible over SSH (for example, ubuntu@ec2-public-ip)
  • STACK_NAME - is new Docker stack name (use "vote", for example)
  • SSH_KEY - private SSH key, used to access Docker swarm master machine
  • SPLIT_CHAR - split character, you've used to replace newline in SSH key. Recommendation: use , (comma character).

Passing SSH key through ENV variable

Currently in order to pass SSH key through Codefresh UI, you need to convert it to single line string (replacing newline with comma), like this:

$ SSH_KEY=$(cat ~/.ssh/my_ssh_key_file | tr '\n' ',')
You can’t perform that action at this time.