Environment
- 8. Environment - Production environment
- Setting where your product is actually put into operation for their intended
uses by end users
- Could be thought of as a real-time setting where programs are run hardware
setups are installed and relied on for organization or commercial daily
operations
- In testing environment a product is still being used theoretically. In the
production environment, the product has been delivered and needs to work
flawlessly
- 9. Environment - Production environment
- Code is frozen
- Services are high-stable
- All of possible cacheable things is cached
- Assets are precompiled
- Contains at least TWO servers:
- HTTP-server
- Web-server
- DB is being backed up regularly
- Virtual server is secured
- 10. Environment - General principles
Copy sourcesCreate dir for release Run bundle
Run DB migrationsPrecompile assets
Link “current” to the
new release
Unlink old symlink Restart Web Server Reset Cache
- 12. Environment - Docker
VIRTUALIZATION CONTAINER
S
APP
GUEST OS
APP
GUEST OS
APP
GUEST OS
HYPERVISOR
HOST OPERATING SYSTEM
APP
SUPPORTING
FILES
RUNTIME
APP APP
SUPPORTING
FILES
RUNTIME
APP
HOST OPERATING SYSTEM
- 15. Environment - Docker Compose
Dockerfile
FROM ruby:2.4
RUN apt-get update -qq && apt-get install -y curl apt-transport-https build-essential libpq-dev
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app
- 16. Environment - Docker Compose
Native Docker Compose Based
- Database
- Redis
- Sidekiq
- Rails app
- Elasticsearch
- Code
Database
RedisSidekiq
Rails app
Elasticsearch
Code
- 17. Environment - Docker Compose
Project folder
app/
Gemfile
Gemfile.lock
Dockerfile
docker-compose.yml
- 18. Environment - Docker Compose
docker-compose.yml
version: '3'
services:
db:
image: postgres
ports:
- 5432:5432
redis:
image: redis:4-alpine
ports:
- 6379:6379
web:
build: .
ports:
- 3000:3000
depends_on:
- redis
- db
WEB
REDIS
DB
- 19. Environment - Deployment Keys and Security
- Do not keep secret information in the repository
- Do not keep env files in the repository
- Do not use standard SSH ports
- Do not make your services open-for-world
- Disable remote access to your services
- Encrypt sensitive data
- Store sensitive data in the ENV
- Use secured SSL