Task L - Deployment and Production - Agile Web Development With Rails 81
Task L - Deployment and Production - Agile Web Development With Rails 81
We cover: Chapter 17
Running our application in a
production web server
Configuring the database for
PostGreSQL
Task L:
Securely deploying secrets
Placing all of the above into Deployment and
Docker containers
Production
Deployment is supposed to mark a happy point in the lifetime of our ap-
plication. It’s when we take the code that we’ve so carefully crafted and
upload it to a server so that other people can use it. It’s when the beer,
champagne, and hors d’oeuvres are supposed to flow. Shortly thereafter,
our application will be written about in Wired magazine, and we’ll be
overnight names in the geek community.
The reality, however, is that it often takes quite a bit of up-front planning
to pull off a smooth and repeatable deployment of your application.
At the moment, we’ve been doing all of our work on one machine, though
user interaction with our web server could be done on a separate ma-
chine. On our machine you’ve been making use of the Puma web server,
SQLite 3, various gems you’ve installed, and your application code. Your
code may or may not have also been placed in Git by this point.
https://learning.oreilly.com/library/view/agile-web-development/9798888650288/f_0091.xhtml 1/3
12/06/2023, 18:09 17. Task L: Deployment and Production | Agile Web Development with Rails 7
For deployment, we’re going to make use of two Docker containers. The
web server container will be running a combination of nginx[80] and
Phusion Passenger.[81] This code will access a PostgreSQL database run-
ning in a separate container.[82]
That’s a lot of moving parts! To help us keep track of them all, we’ll be us-
ing Bundler to manage our dependencies and Docker Compose as the tool
to manage the containers.[83] And yet, despite all the moving parts, the
overall definition is remarkably compact:
rails7/depot_td/docker-compose.yml
version:
"3.8"
services:
db:
image:
postgres:14
volumes:
- p
gdata:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD:
password
web:
build:
.
volumes:
- .
/log:/home/app/depot/log
secrets:
- source:
master_key
target:
/home/app/depot/config/master.key
ports:
- "
8001:80"
depends_on:
- d
b
secrets:
master_key:
file: .
/config/master.key
https://learning.oreilly.com/library/view/agile-web-development/9798888650288/f_0091.xhtml 2/3
12/06/2023, 18:09 17. Task L: Deployment and Production | Agile Web Development with Rails 7
volumes:
pgdata:
Don’t let the size of the file fool you—there’s a lot to unpack here. We’ll
cover the following in subsequent sections:
https://learning.oreilly.com/library/view/agile-web-development/9798888650288/f_0091.xhtml 3/3