Skip to content

Commit 3c27c2e

Browse files
committed
Add 03 and 04 sections (well, mostly a placeholder for 04)
1 parent 330d550 commit 3c27c2e

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

docs/03-adding-dev-tools.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# 🛠️ Adding dev tools
2+
3+
Before we talk about building and packaging our application as a container image, we want to show one additional capability of using containers for development - **the ease of adding additional tools.**
4+
5+
As we were working in the previous section, we had to use the `psql` command quite a bit. But, not everyone is familiar with `psql`.
6+
7+
What if we could add a web-based tool to make it easier to navigate and work with our database?
8+
9+
Fortunately, there is an open-source tool called [pgAdmin](https://www.pgadmin.org/) that ships a container image! Sweet!
10+
11+
12+
## Adding pgAdmin to our stack
13+
14+
Since pgAdmin is already a containerized application, we can simply add it to our `compose.yaml`.
15+
16+
1. In the `compose.yaml` file, add the following configuration:
17+
18+
```yaml
19+
services:
20+
pgadmin:
21+
image: dpage/pgadmin4:9.6.0
22+
ports:
23+
- 5050:80
24+
environment:
25+
PGADMIN_DEFAULT_EMAIL: [email protected]
26+
PGADMIN_DEFAULT_PASSWORD: secret
27+
PGADMIN_CONFIG_SERVER_MODE: 'False'
28+
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: 'False'
29+
depends_on:
30+
- db
31+
```
32+
33+
**NOTE:** If you copy the snippet above, remove the first `services` field.
34+
35+
Looking at the `compose.yaml` file, you should now have a single `services` field with two defined services - `db` and `pgadmin`.
36+
37+
2. Use `docker compose` to update the running stack:
38+
39+
```bash
40+
docker compose up -d
41+
```
42+
43+
Note that we did NOT have to tear down the existing stack. Compose is smart enough to figure out what changes were made and automatically apply them.
44+
45+
3. Open your browser to http://localhost:5050. Note that it may take a moment for the app to startup. If you need to, you can check the logs by using `docker compose logs`:
46+
47+
```bash
48+
docker compose logs pgadmin
49+
```
50+
51+
4. In the middle of the screen in the **Quick Links** section, click on the **Add New Server** link.
52+
53+
5. In the _General_ tab, enter a name of "Development".
54+
55+
6. In the _Connection_ tab, enter the following config:
56+
57+
- **Host name/address**: db
58+
- **Password**: secret
59+
- **Save password?** Enable the toggle
60+
61+
7. Click the **Save** button.
62+
63+
8. To view the table content, use the left side nav (named **Object Explorer**) to navigate to **Servers** -> **Development** -> **Databases** -> **postgres** -> **Schemas** -> **public** -> **Tables** -> **memes**.
64+
65+
9. Right-click on the _memes_ table and select **View/Edit Data** -> **All Rows**.
66+
67+
If you'd like feel free to make any changes to the database you'd like!
68+
69+
70+
71+
### Auto-configuring pgAdmin
72+
73+
You may be thinking "Wow! This is cool, but I still had to do a few things to set everything up." And you're not wrong! It would be great to provide a seamless experience to our developers.
74+
75+
Many apps provide the ability to provide this configuration at startup, pgAdmin included. That configuration requires a few files to be defined, which go beyond the scope of this training. But, we can define them in our code base and mount them into the pgAdmin container, just as we did for the database containers.
76+
77+
78+
79+
## 🐳 Docker Recap
80+
81+
Before moving on, let's take a step back and focus on what we learned.
82+
83+
- 🎉 **No install required.** Just as with the database, we can add other containerized services without spending time on setup and configuration.
84+
- 🎉 **More than just our app's needs.** While it's great to have our app's dependencies in the project, that's not the only thing that can be in our dev environments.
85+
86+
87+
88+
## Next steps
89+
90+
Now that we've learned how to use containers to help setup our development environment and add additional tools, let's explore how containers can be used to help ensure our apps work as expected!

docs/04-running-tests.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 🧩 Running tests... with containers!
2+
3+
More to come here soon!
4+
5+
## 🐳 Docker recap
6+
7+
Before moving on, let's take a step back and focus on what we learned.
8+
9+
- **Ephemeral test environments.** We no longer need long-running test environments with databases and other services just for testing. We can spin them up when needed and then tear them down, saving on costs and maintenance.
10+
- **No more resource contention.** Building on the previous notes, tests can now run in parallel as they spin up their own resources. No more waiting for another test suite to finish before the database can be used for the next test run.
11+
- **Test consistency.** By using containers in testing, the tests run by developers on their local machines will run the same way as they do in their CI environments. No more "it worked on my machine" for testing!
12+
13+
## What's next?
14+
15+
Now that we've learned about development and testing, let's prepare our application for deployment by containerizing it!

0 commit comments

Comments
 (0)