{"id":21273276,"url":"https://github.com/sclorg/rails-ex","last_synced_at":"2025-10-04T06:17:22.132Z","repository":{"id":32665071,"uuid":"36252974","full_name":"sclorg/rails-ex","owner":"sclorg","description":"Ruby Rails Example","archived":false,"fork":false,"pushed_at":"2024-09-24T11:55:37.000Z","size":325,"stargazers_count":35,"open_issues_count":0,"forks_count":344,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-01-22T03:09:13.500Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sclorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-25T20:29:08.000Z","updated_at":"2024-09-24T11:54:39.000Z","dependencies_parsed_at":"2024-07-22T12:44:52.172Z","dependency_job_id":null,"html_url":"https://github.com/sclorg/rails-ex","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sclorg%2Frails-ex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sclorg%2Frails-ex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sclorg%2Frails-ex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sclorg%2Frails-ex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sclorg","download_url":"https://codeload.github.com/sclorg/rails-ex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732252,"owners_count":20338831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T09:13:17.160Z","updated_at":"2025-10-04T06:17:17.073Z","avatar_url":"https://github.com/sclorg.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003c!-- toc --\u003e\n\n- [Rails Sample App on OpenShift](#rails-sample-app-on-openshift)\n  * [OpenShift Considerations](#openshift-considerations)\n    + [Assets](#assets)\n    + [Security](#security)\n    + [Development mode](#development-mode)\n    + [Installation](#installation)\n    + [Debugging Unexpected Failures](#debugging-unexpected-failures)\n    + [Adding Webhooks and Making Code Changes](#adding-webhooks-and-making-code-changes)\n    + [Enabling the Blog example](#enabling-the-blog-example)\n    + [Hot Deploy](#hot-deploy)\n    + [Compatibility](#compatibility)\n    + [License](#license)\n\n\u003c!-- tocstop --\u003e\n\nRails Sample App on OpenShift\n============================\n\nThis is a quickstart Rails application for OpenShift v3 that you can use as a starting point to develop your own application and deploy it on an [OpenShift](https://github.com/openshift/origin) cluster.\n\nIf you'd like to install it, follow [these directions](https://github.com/sclorg/rails-ex/blob/master/README.md#installation).  \n\nThe steps in this document assume that you have access to an OpenShift deployment that you can deploy applications on.\n\nOpenShift Considerations\n------------------------\nThese are some special considerations you may need to keep in mind when running your application on OpenShift.\n\n### Assets\nYour application is set to precompile the assets every time you push to OpenShift.\nAny assets you commit to your repo will be preserved alongside those which are generated during the build.\n\nBy adding the ```DISABLE_ASSET_COMPILATION=true``` environment variable value to your BuildConfig, you will disable asset compilation upon application deployment.  See the [Basic Build Operations](https://docs.okd.io/latest/dev_guide/builds/basic_build_operations.html#starting-a-build) documentation on setting environment variables for builds in OpenShift V3.\n\n### Security\nSince these quickstarts are shared code, we had to take special consideration to ensure that security related configuration variables are unique across applications. To accomplish this, we modified some of the configuration files. Now instead of using the same default values, OpenShift can generate these values using the generate from logic defined within the template.\n\nOpenShift stores these generated values in configuration files that only exist for your deployed application and not in your code anywhere. Each of them will be unique so initialize_secret(:a) will differ from initialize_secret(:b) but they will also be consistent, so any time your application uses them (even across reboots), you know they will be the same.\n\nTLDR: OpenShift can generate and expose environment variables to your application automatically. Look at this quickstart for an example.\n\n### Development mode\nWhen you develop your Rails application in OpenShift, you can also enable the 'development' environment by setting the RAILS_ENV environment variable for your deploymentConfiguration, using the `oc` client, like:  \n\n\t\t$ oc set env dc/rails-postgresql-example RAILS_ENV=development\n\n\nIf you do so, OpenShift will run your application under 'development' mode. In development mode, your application will:  \n*  Show more detailed errors in the browser  \n*  Skip static assets (re)compilation  \n\nDevelopment environment can help you debug problems in your application in the same way as you do when developing on your local machine. However, we strongly advise you to not run your application in this mode in production.\n\n### Installation\nThese steps assume your OpenShift deployment has the default set of ImageStreams defined. Instructions for installing the default ImageStreams are available [here](https://docs.okd.io/latest/install_config/imagestreams_templates.html).  If you are defining the set of ImageStreams now, remember to pass in the proper cluster-admin credentials and to create the ImageStreams in the 'openshift' namespace.\n\n1. Fork a copy of [rails-ex](https://github.com/sclorg/rails-ex)\n2. Clone your repository to your development machine and cd to the repository directory\n3. Add a Ruby application from the rails template:\n\n\t\t$ oc new-app openshift/templates/rails-postgresql.json -p SOURCE_REPOSITORY_URL=https://github.com/\u003c yourusername \u003e/rails-ex \n\n4. Depending on the state of your system, and whether additional items need to be downloaded, it may take around a minute for your build to be started automatically.  If you do not want to wait, run\n\n\t\t$ oc start-build rails-postgresql-example\n\n5. Once the build is running, watch your build progress  \n\n\t\t$ oc logs build/rails-postgresql-example-1\n\n6. Wait for rails-postgresql-example pods to start up (this can take a few minutes):  \n\n\t\t$ oc get pods -w\n\n\n\tSample output:  \n\n\t\tNAME                    READY     REASON         RESTARTS   AGE\n\t\tpostgresql-1-vk6ny                   1/1       Running        0          4m\n\t\trails-postgresql-example-1-build     0/1       ExitCode:0     0          3m\n\t\trails-postgresql-example-1-deploy    1/1       Running        0          34s\n\t\trails-postgresql-example-1-prehook   0/1       ExitCode:0     0          32s\n\n\n\n7. Check the IP and port the rails-postgresql-example service is running on:  \n\n\t\t$ oc get svc\n\n\n\tSample output:  \n\n\t\tNAME             LABELS                              SELECTOR              IP(S)           PORT(S)\n\t\tpostgresql                 template=rails-postgresql-example   name=postgresql                 172.30.197.40    5432/TCP\n\t\trails-postgresql-example   template=rails-postgresql-example   name=rails-postgresql-example   172.30.205.117   8080/TCP\n\n\nIn this case, the IP for rails-postgresql-example rails-postgresql-example is 172.30.205.117 and it is on port 8080.  \n*Note*: you can also get this information from the web console.\n\n\n### Debugging Unexpected Failures\n\nReview some of the common tips and suggestions [here](https://github.com/openshift/origin/blob/master/docs/debugging-openshift.md).\n\n### Adding Webhooks and Making Code Changes\nSince OpenShift V3 does not provide a git repository out of the box, you can configure your github repository to make a webhook call whenever you push your code.\n\n1. From the Web Console homepage, navigate to your project\n2. Click on Browse \u003e Builds\n3. Click the link with your BuildConfig name\n4. Click the Configuration tab\n5. Click the \"Copy to clipboard\" icon to the right of the \"GitHub webhook URL\" field\n6. Navigate to your repository on GitHub and click on repository settings \u003e webhooks \u003e Add webhook\n7. Paste your webhook URL provided by OpenShift\n8. Leave the defaults for the remaining fields - That's it!\n9. After you save your webhook, if you refresh your settings page you can see the status of the ping that Github sent to OpenShift to verify it can reach the server.  \n\n### Enabling the Blog example\nIn order to access the example blog application, you have to remove the\n`public/index.html` which serves as the welcome page and rebuild the application.\nAnother option is to make a request directly to `/articles` which will give you access to the blog.\n\nThe username/pw used for authentication in this application are openshift/secret.\n\n### Hot Deploy\n\nIn order to dynamically pick up changes made in your application source code, you need to set the `RAILS_ENV=development` parameter to the [oc new-app](https://docs.okd.io/latest/cli_reference/basic_cli_operations.html#basic-cli-operations) command, while performing the [installation steps](https://github.com/sclorg/rails-ex#installation) described in this README.\n\n\t$ oc new-app openshift/templates/rails-postgresql.json -p RAILS_ENV=development\n\nTo change your source code in the running container you need to [oc rsh](https://docs.okd.io/latest/cli_reference/basic_cli_operations.html#troubleshooting-and-debugging-cli-operations) into it.\n\n\t$ oc rsh \u003cPOD_ID\u003e\n\nAfter you [oc rsh](https://docs.okd.io/latest/cli_reference/basic_cli_operations.html#troubleshooting-and-debugging-cli-operations) into the running container, your current directory is set to `/opt/app-root/src`, where the source code is located.\n\nTo set your application back to the `production` environment you need to remove `RAILS_ENV` environment variable:\n\n\t$ oc set env dc/rails-postgresql-example RAILS_ENV-\n\nA redeploy will happen automatically due to the `ConfigChange` trigger.\n\n**NOTICE: If the `ConfigChange`  trigger is not set, you need to run the redeploy manually:**\n \n\t$ oc deploy rails-postgresql-example --latest\n\n### Compatibility\n\nThis repository is compatible with Ruby 2.3 and higher, excluding any alpha or beta versions.\n\n### License\nThis code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to [CC0](http://creativecommons.org/publicdomain/zero/1.0/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsclorg%2Frails-ex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsclorg%2Frails-ex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsclorg%2Frails-ex/lists"}