Coder Social home page Coder Social logo

laerciosb / package-based-rails-applications-book Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shageman/package-based-rails-applications-book

0.0 1.0 0.0 283.34 MB

Shell 1.34% JavaScript 0.03% Ruby 95.49% CSS 0.04% HTML 1.67% Slim 1.43%

package-based-rails-applications-book's Introduction

Source Code to Package-Based Rails Applications by Stephan Hagemann

This repository holds the source code used in my book on Package-based Rails Applications.

It is organized by chapter and section encoded as cXs0Y for "Chapter X, Section Y." If a section adds no code that is specific to it, it may use the source code from the last section preceding it that does have source code samples attached.

Because the Ruby and Rails ecosystems are moving so rapidly, creating a book about high-level structural concepts is tough when underlying libraries constantly require subtle changes to the sample code. To this end, all source code packages its gem dependencies.

References

Development

The docker and generator_scripts folders are for development of the chapter samples. In fact, all of the samples were generated via script in a concourse pipeline. I.e., every transformation described in a chapter can be executed via the shell script belonging to that chapter.

These instructions assume that you have docker running on OSX.

Starting Concourse and Minio on Docker

Concourse acts as our CI server, which will run the pipeline. Minio is our local S3 compatible serverm, which will hold the outputs of the pipeline.

In one terminal execute the following to install the needed docker containers.

docker-compose up

The services should be running at these locations:

If any of the containers fail to start, please check the docs of the docker images used for updates to their respective config:

Get the Pipeline Running

Concourse gets configured via its fly CLI. Download it here. Or on Mac with brew installed via brew cask install fly.

To point fly at the locally running instance of concourse, first do this (and follow the instructions on screen). The above concourse installation gave you a user test with password test.

fly --target local login --team-name main --concourse-url http://localhost:8080

Then, to configure and start the pipeline

fly -t local set-pipeline -p pipeline -c pipeline.yml --load-vars-from  pipeline-secrets.yml
fly -t local unpause-pipeline -p pipeline
fly -t local trigger-job -j pipeline/c2s01

Now, navigating to http://localhost:8080/teams/main/pipelines/pbra_full will show the running pipeline.

The output of the pipeline is all of the versions of the Sportsball codebase discussed in the book. Specifically, the output is a series of zip files in ./docker/minio/data/releases - one zip file for each chapter / step of the pipeline.

Updating the version of Rails to run against

The folder code/docker/minio/data/releases contains a couple of files named app_XYZ.tgz. These are archives of empty starter apps. These are empty Rails apps with just a few gems added (generated by code/generator_scripts/ci/generate-code.sh). For the rest of the pipeline, this locks down the dependencies that will be used for the generation of the chapter code.

You can manually start the generate-empty-app concourse step to generate an empty app with the current version of Rails and the other dependencies of the app.

Every run of the chapter-generation pipeline will use the latest version of Rails found in this folder. If you happen to delete all of the app archives, the chapter-generation pipeline will not work. In that case, either generate a new empty app or reset to the state of this repo to get the pipeline running again.

Issues

If your pipelines don't work after a docker shutdown, try fly prune-worker.

If things are still broken, repeat the above steps after doing this (careful: this will wipe out all of the docker images and their disks running on your machine):

docker stop $(docker ps -aq)     # Stop all running containers
docker rm $(docker ps -a -q)     # Delete all containers
docker rmi $(docker images -q)   # Delete all images
docker volume prune
docker system prune -a

What goes wrong?

  • concourse can't find generator_scripts anymore (errors with "no such file"). Definitely do the above
  • nothing works reliably anymore. Reinstall docker.

Speeding up the pipeline

Some recent issues with concourse-docker have forced me to rerun the code build pipeline from the very start a lot. If there are changes to the steps at the tail of the pipeline only, the following calls speed up the time to get there:

fly pause-job -t local -j pipeline/c2s01-test
fly pause-job -t local -j pipeline/c2s02-test
fly pause-job -t local -j pipeline/c2s03-test
fly pause-job -t local -j pipeline/c2s04-test
fly pause-job -t local -j pipeline/c2s05-test
fly pause-job -t local -j pipeline/c2s06-test

fly pause-job -t local -j pipeline/c4s01-test
fly pause-job -t local -j pipeline/c4s02-test
fly pause-job -t local -j pipeline/c4s03-test

fly pause-job -t local -j pipeline/c5s07-1-test
fly pause-job -t local -j pipeline/c5s07-2-test
fly pause-job -t local -j pipeline/c5s07-3-test
fly pause-job -t local -j pipeline/c5s08-test
fly pause-job -t local -j pipeline/c5s09-test

fly pause-job -t local -j pipeline/c6s01-test
fly pause-job -t local -j pipeline/c6s02-test
fly pause-job -t local -j pipeline/c6s03-test
fly pause-job -t local -j pipeline/c6s04-1-test
fly pause-job -t local -j pipeline/c6s04-2a-test
fly pause-job -t local -j pipeline/c6s04-2b-test



fly pause-job -t local -j pipeline/c4s01
fly pause-job -t local -j pipeline/c4s02
fly pause-job -t local -j pipeline/c5s08
fly pause-job -t local -j pipeline/c6s04-1

package-based-rails-applications-book's People

Contributors

shageman 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.