https://github.com/bbc2/dockerfoo
https://github.com/bbc2/dockerfoo
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bbc2/dockerfoo
- Owner: bbc2
- License: mit
- Created: 2023-08-16T21:13:39.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-16T10:14:59.000Z (about 1 year ago)
- Last Synced: 2025-01-26T00:24:26.779Z (4 months ago)
- Language: Python
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dockerfoo
Demonstration of a development environment with Docker Compose.
## Prerequisites
- Python Poetry
- Docker Compose## Usage
### Development
Build the container images:
```sh
make build
```Spin up the database:
```sh
make serve
```If this is the first time you run this target, the makefile will generate secrets in
`.secrets`.Run the CLI:
```sh
make run-cli # This opens a new shell in the CLI container.
``````sh
dockerfoo init
dockerfoo seed --count 1000000
```For debugging, you can use the `pqsl` program:
```sh
make run-db-ops # This opens a new psql CLI connected to the database.
``````pgsql
\d
select count(*) from tokens
```If you want to delete the database and start over:
```sh
make reset-db # This deletes the Docker volume containing the database files.
```### Production
To use the CLI in production mode, set the following environment variable:
```sh
DF_MODE=prod make build run-cli
```In production mode, the container has only the production code and no mount point. By
default, `DF_MODE` is `dev`.## Architecture
### Environment
Almost everything runs in Docker. Notable exceptions are unit tests, code linting and
package updates.### Code
This project is currently primarily a CLI (`dockerfoo`) which can initialize and update
a database. However, this architecture should be suitable for a web application as well.```
src/dockerfoo
├── cli: CLI subcommands
├── sql: SQLAlchemy models (no connection code)
├── db: Database connection utilities
└── util: Generic utilities (e.g. timing code)
```