Skip to content

guillaumebriday/lobsters-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker build status Docker Pulls Docker Stars

Lobsters in a Docker container

This repo is designed to automatically build an image of Lobsters to use it in a production environmment on Docker.

Environment variables

Database

  • -e DATABASE_URL Defaults to "mysql2://root:password@lobsters-db/lobsters".

Where mysql2 is the adapter, root is the username, password is the password, lobsters-db is the host, and lobsters the name of database.

In this example, lobsters-db should be the name of the mysql container.

More informations: https://edgeguides.rubyonrails.org/configuring.html#configuring-a-database

Application

  • -e APP_DOMAIN Defaults to "example.com". This should be your domain name.
  • -e APP_NAME Defaults to "Example News". This should be your application name.
  • -e SECRET_KEY_BASE Defaults to "". If empty a generic key will be generated.
  • -e X_SENDFILE_HEADER Defaults to "". Specifies the header that your server uses for sending files.
  • -e RAILS_SERVE_STATIC_FILES Defaults to "true". If present then Puma will serve static asset.

Email

  • -e SMTP_HOST Defaults to "127.0.0.1".
  • -e SMTP_PORT Defaults to "25".
  • -e SMTP_STARTTLS_AUTO Defaults to "true".
  • -e SMTP_USERNAME Defaults to "".
  • -e SMTP_PASSWORD Defaults to "".

Starting the containers

Change or add the environmment variables to suit your needs, then run:

# Starting the mysql container
$ docker run --name lobsters-db -v /my/own/datadir:/var/lib/mysql -e "MYSQL_ROOT_PASSWORD=password" -e "MYSQL_DATABASE=lobsters" -d mysql:5.7

# Starting the lobsters container
$ docker run --name lobsters --link lobsters-db -p 3000:3000 -d guillaumebriday/lobsters-docker

You can use this docker-compose for this project:

$ docker-compose up -d

Administration

In lobsters, as mentioned in the documentation:

Basic moderation happens on-site, but most other administrative tasks require use of the rails console in production.

To open a console in production:

$ docker run --rm -it --link lobsters-db guillaumebriday/lobsters-docker bundle exec rails c

# Or with docker-compose
$ docker-compose run --rm lobsters bundle exec rails c

Credits

Inspired by:

Contributing

Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

License

This project is released under the MIT license.