Coder Social home page Coder Social logo

cwock's Introduction

( code fresh )

Cwock — the time-oriented microblog

A Codefresh demo / Getting Started with Codefresh on Rails.

Intro-Promo

You’re a full-stack developer on Rails. And you’d like setup and maintenance of your servers to be smooth. As smooth as development in Ruby is. Docker-smooth. Plus, you probably work in a team. We’ve got you. Wrap your stack up, afresh.

In case you’re still wondering, working with containers makes you even full-stack-er. Now however full-stack you are, setting servers up isn’t your job, still if DevOps write your Dockerfile for you, you’re probably doing it wrong.

Codefresh will connect to your repository, build docker images when you push to branches, run tests in its hosted “on-demand” environments, then — upon success — upload the images to docker hub, and even launch pre-configured environments on demand. You and your team will have instant access to and clear visibility of your running and deployable containers, at codefresh.io and through webhook-based integrations.

We encourage you to learn more about the Docker container technologies and here’s a nice article on Ruby on Rails on Docker Compose you may start with.

Brief Walkthrough

+ Welcome! Feel free to look around and ask questions

  • Click on Add Service

  • Choose your Repository and Branch, click on Next

  • Choose Rails Dockerfile if you don’t have one in the repo, click on Next

  • If you have your Dockerfile in the repo, compare to our generic Rails Dockerfile, change the former as appropriate

  • If you don’t have one in the repo, review the generated Dockerfile, click on Next

  • Make sure the (unit) Test script is empty, click on Create

  • Review the results, click on Close & Build

  • Click on +‘s to see the logs, see that the build succeeds

+ Hooray! You’ve got your first service automatic image build set up: whenever you push to the repository, Codefresh will build automatically and notify on any unfortunate failures

  • Click on the cogwheel, review your Settings

  • Make sure Image Name matches your docker hub username (e.g. docker_hub_user/repo)

  • Click on Push to Docker Registry, click on the Docker Hub icon, follow the instructions, click on Save

  • Click on Build (click on Launch dropdown if needed)

  • Click on +‘s to see the logs, see that the build succeeds

+ Hooray! Your image will be pushed to the registry on every successful build

  • Click Compositions, enter ‘staging’ for the Name, click the test area on the left, paste the following:

    web:
      image: codefresh/cwock:master
      ports:
        - 3000
      links:
        - db
    db:
      image: postgres
  • Replace ‘codefresh/cwock:master’ with your docker_hub_user/repo:branch

  • Review your repo’s ‘config/database.yml` and make sure the settings above match `adapter:` and `host:` there (`postgresql` and `db` respectively)

  • Click on Save, bookmark the URL, click on Launch

  • Click on +‘s to see the logs, see that the launch succeeds

  • Click on Open App and see your app running at our crafted URL

+ Hooray! You have just effortlessly run your first composition, you may even send someone (QA?) the link to your running staging server

  • Go back to Codefresh, click on Services

  • Click on the cogwheel (Settings) of your app service, click on the Integration Test

  • Paste the following (a command to run the specs inside the ‘web` component we’ve specified above)

    docker exec integration_web_1 bash -c "bin/rake db:test:prepare spec"
  • Select Run tests with composition, choose Staging, click on Save

  • Click on Build (click on Launch dropdown if needed)

  • Click on +‘s to see the logs, see that the build succeeds…

+ Wait! If you cloned our sample repository above, it actually fails, since we forgot to add the {specs}[https://www.relishapp.com/rspec/rspec-rails/docs] themselves, let’s do just that

  • Archive that your-build-failed message from Codefresh (delivered to your email registered with your GitHub/Bitbucket)

  • Make sure your local development is set up

  • Add the gem to your Gemfile

    group :test, :development do
      gem 'rspec-rails'
    end
    
  • Run ‘bundle`, run `bin/rails generate rspec:install` in your working directory

  • Then run ‘bin/rails generate rspec:model note` and `bin/rails generate rspec:controller notes`

  • Write some specs, such as, for controller:

    RSpec.describe NotesController, type: :controller do
    
      render_views
    
      describe 'GET index' do
    
        it "should be OK" do
          get :index
          expect(response).to be_success
        end
    
      end
    
    end
    
  • Commit, push, wait for that…

  • …and have Codefresh deliver your-build-successful email to you right away

+ Hooray! Stretch, your project is set up, now every push to your repo/branch will trigger a build just like this and you will get a notification if it fails…

+ …and if it doesn’t fail, you may always go to the URL you bookmarked above, click on Launch and then, on Open App, to go straight to your freshly started staging server

  • When your code is tested and ready for production, click on Images, see your successfully built image with the latest commit message

  • Click up arrow / Promote on that image, enter ‘production’ (the tag you will use for production-deployed images)

  • Now go set up your production environment (e.g. with {Docker Cloud}{cloud.docker.com}) where you can set deploy and auto-re-deploy processes based on tags

+ We’re done and we’ve done well, {contact Codefresh}[mailto:[email protected]] if you need help with anything on the way or just wish to share your experience

Take a generic Rails app…

You’re welcome to clone github.com/codefresh-io/cwock (fork it on github or import it on BitBucket).

Currently, Codefresh works with either GitHub or Bitbucket, with git being the supported source control technology, so familiarity with the latter as well as the repository being hosted at GitHub (or Bitbucket) would be the only prerequisite to get started.

TBD

To dock or not to dock?

You can use Codefresh knowing nothing of Docker.

TBD

…and dock it!

TBD

Ok, now what about Cwock??

TBD

cwock's People

Contributors

costa avatar techmaniack avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.