├── .dockerignore ├── .github └── issue_template.md ├── .gitignore ├── .ruby-version ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── Readme.md ├── check.rb ├── check.sh ├── codeship-services.yml └── codeship-steps.yml /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | Dockerfile 3 | Readme.md 4 | codeship-services.yml 5 | codeship-steps.yml 6 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | Please don't create new issues on this repository when you experience issues with your builds on https://codeship.com, want to request new features for the CI system or have general questions on how to use Codeship for your projects. 2 | 3 | In all of the above cases, reach out to our support team at support@codeship.com or on Twitter at https://twitter.com/CodeshipSupport. 4 | 5 | If you want to report an issue with Codeship Documentation, please open an issue at https://codeship.com/documentation. 6 | If you are reporting an error in the tutorial, please include the following: 7 | 8 | - Exact location of error 9 | - Proposed change, if any 10 | - Any relevant logs. 11 | 12 | Thanks! 🚢 13 | 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeship/codeship-pro-tutorial/ead0231e08cc44007ff886710059da430cc47e08/.gitignore -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.3.0 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting one of the project maintainers listed below. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Project Maintainers 69 | 70 | * Marko Locher (Codeship Inc.) <> 71 | * Brendan Fosberry (Codeship Inc.) <> 72 | 73 | ## Attribution 74 | 75 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 76 | available at [http://contributor-covenant.org/version/1/4][version] 77 | 78 | [homepage]: http://contributor-covenant.org 79 | [version]: http://contributor-covenant.org/version/1/4/ 80 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Start with the offical image for Ruby 2.3.0 2 | FROM ruby:2.3.0 3 | 4 | # Update the base system and install any required dependencies 5 | RUN apt-get update -qq && apt-get install -y netcat 6 | 7 | # You could install further dependencies via e.g. 8 | # RUN apt-get install \ 9 | # apt-utils \ 10 | # build-essential 11 | 12 | # Create the folders needed by the application and set the current working 13 | # directory for the following commands 14 | RUN mkdir /app 15 | WORKDIR /app 16 | 17 | # Copy over the Gemfile and run bundle install. 18 | # This is done as a separate steps so the image can be cached this step won't be 19 | # rerun unless you change the Gemfile or Gemfile.lock 20 | COPY Gemfile Gemfile.lock /app/ 21 | RUN bundle install --jobs 20 --retry 5 22 | 23 | # Copy the complete application onto the container 24 | COPY . /app 25 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | ruby '2.3.0' 4 | 5 | gem 'redis' 6 | gem 'pg' 7 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | pg (0.18.4) 5 | redis (3.2.2) 6 | 7 | PLATFORMS 8 | ruby 9 | 10 | DEPENDENCIES 11 | pg 12 | redis 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Codeship Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Codeship Pro Tutorial 2 | 3 | Please see our Codeship Pro [Getting Started](https://documentation.codeship.com/pro/getting-started/getting-started/) tutorial for the full text as well as installation instructions for the CLI. 4 | 5 | ## Quick Setup 6 | 7 | Once you have the CLI installed, clone this repository via 8 | 9 | ```bash 10 | git clone https://github.com/codeship/codeship-pro-tutorial.git 11 | ``` 12 | 13 | and then run the build via 14 | 15 | ```bash 16 | cd codeship-pro-tutorial 17 | jet steps 18 | ``` 19 | 20 | ## Submitting an Issue 21 | We use the [GitHub issue tracker][issues] to track bugs and features for this tutorial. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. When submitting a bug report, please include any details that may be necessary to reproduce the bug. 22 | 23 | ## Submitting a Pull Request 24 | 1. [Fork the repository.][fork] 25 | 2. [Create a topic branch.][branch] 26 | 3. Implement your feature or bug fix. 27 | 4. Add, commit, and push your changes. 28 | 5. [Submit a pull request.][pr] 29 | 30 | ## When not to submit an issue 31 | 32 | Please don't create new issues on this repository when you experience issues with your builds on https://codeship.com, want to request new features for the CI system or have general questions on how to use https://codeship.com or the Docker Infrastructure for your projects. 33 | 34 | In all of the above cases, reach out to our support team at support@codeship.com or on Twitter at [@CodeshipSupport](https://twitter.com/CodeshipSupport). 35 | 36 | *This file was taken from https://github.com/middleman/middleman-heroku/blob/master/CONTRIBUTING.md and extended for use with the Codeship documentation.* 37 | 38 | [issues]: https://github.com/codeship/jet-tutorial/issues 39 | [fork]: http://help.github.com/fork-a-repo/ 40 | [branch]: https://github.com/blog/1377-create-and-delete-branches 41 | [pr]: http://help.github.com/send-pull-requests/ 42 | -------------------------------------------------------------------------------- /check.rb: -------------------------------------------------------------------------------- 1 | require "redis" 2 | require "pg" 3 | 4 | def log(message) 5 | puts "\e[34m#{message}\e[0m" 6 | end 7 | 8 | log "Checking Redis server..." 9 | begin 10 | redis = Redis.new() 11 | redis.ping 12 | log "REDIS VERSION: #{redis.info["redis_version"]}" 13 | rescue Redis::CannotConnectError => e 14 | STDERR.puts(e.message) 15 | exit 1 16 | end 17 | 18 | log "Checking PostgreSQL server..." 19 | begin 20 | pg = PG.connect({ 21 | host: ENV['POSTGRES_HOST'], 22 | dbname: ENV['POSTGRES_DB'], 23 | user: ENV['POSTGRES_USER'], 24 | }) 25 | log pg.exec("SELECT version();").first["version"] 26 | rescue PG::Error => e 27 | STDERR.puts("PostgreSQL connection failed") 28 | exit 2 29 | end 30 | -------------------------------------------------------------------------------- /check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | function check_port() { 5 | local host=${1} && shift 6 | local port=${1} && shift 7 | local retries=25 8 | local wait=1 9 | 10 | until( $(nc -zv ${host} ${port}) ); do 11 | ((retries--)) 12 | if [ $retries -lt 0 ]; then 13 | echo "Service ${host} didn't become ready in time." 14 | exit 1 15 | fi 16 | sleep "${wait}" 17 | done 18 | } 19 | 20 | check_port "postgres" "5432" 21 | check_port "redis" "6379" 22 | 23 | bundle exec ruby check.rb 24 | -------------------------------------------------------------------------------- /codeship-services.yml: -------------------------------------------------------------------------------- 1 | app: 2 | build: 3 | image: app 4 | dockerfile_path: Dockerfile 5 | environment: 6 | REDIS_URL: "redis://redis:6379" 7 | POSTGRES_HOST: postgres 8 | POSTGRES_DB: postgres 9 | POSTGRES_USER: postgres 10 | links: 11 | - redis 12 | - postgres 13 | redis: 14 | image: redis:3.0 15 | postgres: 16 | image: postgres:9.5 17 | -------------------------------------------------------------------------------- /codeship-steps.yml: -------------------------------------------------------------------------------- 1 | - service: app 2 | command: bash check.sh 3 | --------------------------------------------------------------------------------