Sign inSign up

devteds/rails-sample-app

By devteds

Updated almost 9 years ago

Rails example application built and run on docker

Image
1

619

devteds/rails-sample-app repository overview

Rails Application on Docker

Image was built using the application created in devteds Episode 1: Rails on Docker

Please note this image or application dockerization is not production ready. One will need to make a few changes (some are listed below) to make it production ready

  • Do not include or install dev packages in the image. That'll will require you to run the docker build in multi-stage
  • Do not use environment variables for sensitive data such as database passwords and secrets
  • Possibly build a separate image that serve static contents or the assets with web server (eg: nginx) - This is not so much an issue of security / compliance but performance

Docker Compose

version: '3'
services:
  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: noteapp
      MYSQL_USER: appuser
      MYSQL_PASSWORD: password
  app:
    image: devteds/rails-sample-app:latest
    ports:
      - "3002:3000"
    depends_on:
      - db
    environment:
      DB_USER: root
      DB_NAME: noteapp
      DB_PASSWORD: password
      DB_HOST: db
      RAILS_ENV: production
      RAILS_SERVE_STATIC_FILES: 1
      SECRET_KEY_BASE: ed4988f0afd486feea2528004c8c8e45c0b483f5c3fb21e45ee4e6963fa7f51b2e303d36411135bac36b177fe19db6c3a59b1f0fce22b5a832c5fa694b6554c0

Commands

If you create and name the docker compose YAML file as dc-stage.yml with the above content,

docker-compose -f dc-stage.yml up
# and on a seperate terminal
docker-compose -f dc-stage.yml exec app rails db:migrate
docker-compose -f dc-stage.yml exec app rails db:seed

Before executing the above commands, review dc-stage.yml and edit to update host port if needed. Application should be available at http://localhost:3002/notes

References

Tag summary

Content type

Image

Digest

Size

317.9 MB

Last updated

almost 9 years ago

docker pull devteds/rails-sample-app