Giter Club home page Giter Club logo

docker-slim's Introduction

Explanations

https://dev.to/ndrean/realtime-rails-with-websockets-1jk3

Branches

  • Deployed on Heroku: https://pg-redis-cable-sdq.herokuapp.com, but without Sidekiq (2 free dynos only).

  • master <=> run with overmind start -f Procfile.overmind

  • dock-dev <=> run docker-compose up --build

  • docker-prod <=> build images and run docker-compose up --build

  • Kubernets/Minikube <=> start Minikube and run Tilt

Initialize the PostgreSQL database

  • modifiy /config/database.yml (or .env) to pass to the Postgres adapter the desired user/password: POSTGRES_URL=postgresql://bob:bobpwd@localhost:5432/k8_development

  • run in a terminal:

RAILS_ENV=development rails rails db:drop rails:prepare
  • connect to PostgreSQL to create ROLE 'bob' with password "bobpwd"
psql -U postgres
# get list of databases
\l
# connect to the desired database
\c k8_development
CREATE ROLE bob WITH SUPERUSER CREATEDB LOGIN PASSWORD 'bobpwd';

Same database name for primary and replica:

Initialize ElephantSQL database:

CREATE TABLE counters (
  id bigserial PRIMARY KEY,
  nb integer,
  created_at timestamp,
  updated_at timestamp
);

Run overmind

The app is running locally with hot static assets replacement and Rails running in dev mode (page refresh will update the app). Run overmind start to start the four processes rails, webpack-dev-server, redis and sidekiq:

The following runs on OSX (use "redis-server /usr/local/etc/redis.conf" on OSX, and "/usr/local/etc/redis/redis.conf" on Linux ):

assets:  ./bin/webpack-dev-server
web:     bundle exec rails server
redis-server:   redis-server /usr/local/etc/redis.conf
worker:  bundle exec sidekiq -C config/sidekiq.yml
cable: bundle exec puma -p 28080 cable/config.ru

The Redis database

Modify /usr/local/etc/redis/redis.conf with requirespass secretpwd.

Once the app is running (ie redis-server is up), we can check that Redis is protected by the password by connecting to the redis-cli:

redis-cli
127.0.0.1:6379> GET counter
(error) NOAUTH Authentication required
127.0.0.1:6379> AUTH secretpwd
OK
127.0.0.1:6379> GET counter
23

We can setup Redis with AOF and RDB.

Gem sidekiq_alive

https://github.com/arturictus/sidekiq_alive_example

https://github.com/mhfs/sidekiq-failures

https://github.com/mperham/sidekiq/wiki

Example Rackup

Declared a controller "Example_Controller" inheriting from ApplicationController::Base Then "config.ex.ru" and launched with: "bundle exec puma -b tcp://0.0.0.0:3001 config.ex.ru"

=> this is used for cable with /cable/config.ru to run a standalone Cable.

Nginx

 cp nginx/k8nginx.conf /usr/local/etc/nginx/servers/
 nginx -s stop && nginx

The config will pass the web sockets.

docker-slim's People

Contributors

ndrean avatar

Watchers

 avatar  avatar

Forkers

godie

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.