Skip to content

Commit

Permalink
Merge pull request #74 from redjax/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
redjax authored Oct 28, 2024
2 parents fc61264 + 69900db commit 6c62029
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 22 deletions.
1 change: 1 addition & 0 deletions dev.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
volumes:
- ./docs:/project/docs
- ./includes:/project/includes
- ./mkdocs.yml:/project/mkdocs.yml
# expose:
# - 8000
ports:
Expand Down
69 changes: 49 additions & 20 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,59 @@

My personal knowledgebase. Use the sections along the top (i.e. [`Programming`](programming/index.md)) to navigate areas of the KB.

!!! example "Find a mistake?"

Did you spot a spelling error or some other inaccuracy? Feel free to open a PR on [the Github repository](https://github.com/redjax/redkb) for this site! I welcome contributions 😊

??? warning "Warning on content accuracy & freshness"

I make no guarantee at total accuracy, relevant/updated, or topic depth for any of the content on this site. My goal is to keep reference notes for myself in a place accessible over the Internet in an easily-editable format (i.e. the [Github repository](https://github.com/redjax/redkb)).

I aim to be accurate, and notes I reference frequently will be updated more often. Each article on this site has a published and last modified timestamp at the bottom of the page, which you should take note of when referencing content on this site.

## Quick Links

### 🐍 Python
The list below is like a table of contents for the sections I most frequently reference or send to other people. Unless you're coming here for something specific, I recommend browsing through the sections at the top.

??? tip "🐍 Python"
- [Python standard project files](programming/standard-project-files/python/index.md)
- [Python Docker image templates](template/docker/python/index.md)
- [`ruff`](programming/standard-project-files/python/ruff/index.md)
- [`ruff` pyproject.toml `[tool.ruff]` section](programming/standard-project-files/python/ruff/pyproject-ruff.md)
- [Python `.gitignore` file](programming/standard-project-files/python/gitignore.md)
- [`dynaconf`](programming/standard-project-files/python/Dynaconf/index.md)
- [`nox`](programming/python/nox/index.md)
- [`noxfile.py`](programming/python/nox/index.md#noxfilepy-base)
- [`nox_extra`: Make `nox` more modular](programming/python/nox/nox_extra-module/index.md)
- [Manage your Python install with `pyenv`](programming/python/virtualenv.md)
- [Manage your Python projects with the `pdm` package manager](programming/python/pdm.md)
- [Add logging to your project with the stdlib `logging` module](programming/python/logging.md)

??? tip "🅿️ Powershell"
- [Powershell profiles](programming/powershell/profiles/index.md)
- [Powershell code snippets](programming/powershell/snippets/index.md)
- [Powershell modules](programming/powershell/modules/index.md)

??? tip "🛠️ Utilities"
=== "🔑 [SSH](utilities/ssh/index.md)"
- [Create an SSH keypair](utilities/ssh/index.md#create-an-ssh-key-pair)
- [Install SSH key on remote machine](utilities/ssh/index.md#install-an-ssh-key-on-a-remote-machine-for-passwordless-ssh-login.md)

??? tip "📝 Templates"

=== "🐋 Docker Templates"
- [Databases](template/docker/databases/index.md)
- [postgres](template/docker/databases/postgres/index.md)
- [mariadb](template/docker/databases/mariadb/index.md)
- [redis](template/docker/databases/redis/index.md)
- [Python containers](template/docker/python/index.md)

- [`Python standard project files`](programming/standard-project-files/python/index.md)
- [`ruff`](programming/standard-project-files/python/ruff/index.md)
- [`ruff pyproject.toml [tool.ruff] section`](programming/standard-project-files/python/ruff/pyproject-ruff.md)
- [`python .gitignore` file](programming/standard-project-files/python/gitignore.md)
- [`dynaconf`](programming/standard-project-files/python/Dynaconf/index.md)
- [`nox`](programming/python/nox/index.md)
- [`noxfile.py`](programming/python/nox/index.md#noxfilepy-base)
- [`nox_extra`: Make `nox` more modular](programming/python/nox/nox_extra-module/index.md)
- [Manage your Python install with `pyenv`](programming/python/virtualenv.md)
- [Manage your Python projects with the `pdm` package manager](programming/python/pdm.md)
- [Add logging to your project with the stdlib `logging` module](programming/python/logging.md)
---

### 🅿️ Powershell
- [`Powershell profiles`](programming/powershell/profiles/index.md)
- [`Powershell code snippets`](programming/powershell/snippets/index.md)
- [`Powershell modules`](programming/powershell/modules/index.md)
## About

### 🛠️ Utilities
This is a hobby project, something I maintain as I have time/interest. The notes on this site are mostly for myself, but are sometimes helpful to others. The site is loosely based on the concept of a [mind garden](https://elizabethbutlermd.com/personal-knowledge-management/).

#### 🔑 [SSH](utilities/ssh/index.md)
I frequently write Markdown notes in whatever Markdown notes app has most recently caught my attention (honorable mentions to [Obsidian]() and [Logseq]()). I will occasionally dump pages/sections into this KB. You can check the [tags section](tags.md) to quickly find articles on a specific topic.

- [Create an SSH keypair](utilities/ssh/index.md#create-an-ssh-key-pair)
- [Install SSH key on remote machine](utilities/ssh/index.md#install-an-ssh-key-on-a-remote-machine-for-passwordless-ssh-login.md)
I mainly use Linux for my homelab, but work in a Windows environment. I code mainly in Python, Bash, and Powershell, and spend most of my time on the Linux side. The contents of this site skew more heavily towards Linux and the scripting languages I use, but there are also articles on cross-platform tools like SSH and Docker.
2 changes: 1 addition & 1 deletion docs/template/docker/databases/postgres/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ PGADMIN_DATA_DIR=

### docker-compose.yml

```text title="postgresql docker-compose.yml
```text title="postgresql docker-compose.yml"
---
volumes:
postgres_data:
Expand Down
6 changes: 6 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ markdown_extensions:
## Add additional snippets, like *[Annotation]: ... glossaries
auto_append:
- includes/abbreviations.md
- pymdownx.details
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
slugify: !!python/object/apply:pymdownx.slugs.slugify
kwds:
case: lower
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
Expand Down
167 changes: 166 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,172 @@ def _find_free_port(start_port=8000):
log.info(f"Port {port} is in use, trying the next port.")
port += 1

def run_docker_cmd(session: nox.Session, compose_file: str, operation: str):
if compose_file is None:
raise ValueError("Missing a compose_file value.")

if operation is None:
raise ValueError("operation should not be None")

if not check_path_exists(p=compose_file):
raise FileNotFoundError(f"Could not find compose file: {compose_file}")

valid_operations: list[str] = [
"build",
"build-no-cache",
"up",
"up-build",
"up-recreate",
"down",
]

match operation:
case "build":
session.run(
"docker",
"compose",
"-f",
compose_file,
"build",
external=True,
)
case "build-no-cache":
session.run(
"docker",
"compose",
"-f",
compose_file,
"build",
"--no-cache",
external=True,
)
case "up":
session.run(
"docker",
"compose",
"-f",
compose_file,
"up",
"-d",
external=True,
)
case "up-build":
session.run(
"docker",
"compose",
"-f",
compose_file,
"up",
"-d",
"--build",
external=True,
)
case "up-recreate":
session.run(
"docker",
"compose",
"-f",
compose_file,
"up",
"-d",
"--force-recreate",
external=True,
)
case "down" | "stop":
session.run(
"docker",
"compose",
"-f",
compose_file,
"down",
external=True,
)
case _:
raise ValueError(
f"Invalid Docker compose operation: {operation}. Must be one of {valid_operations}"
)


def run_podman_cmd(session: nox.Session, compose_file: str, operation: str):
if compose_file is None:
raise ValueError("Missing a compose_file value.")

if operation is None:
raise ValueError("operation should not be None")

if not check_path_exists(p=compose_file):
raise FileNotFoundError(f"Could not find compose file: {compose_file}")

valid_operations: list[str] = [
"build",
"build-no-cache",
"up",
"up-build",
"up-recreate",
"down",
]

match operation:
case "build":
session.run(
"podman-compose",
"-f",
compose_file,
"build",
external=True,
)
case "build-no-cache":
session.run(
"podman-compose",
"-f",
compose_file,
"build",
"--no-cache",
external=True,
)
case "up":
session.run(
"podman-compose",
"-f",
compose_file,
"up",
"-d",
external=True,
)
case "up-build":
session.run(
"podman-compose",
"-f",
compose_file,
"up",
"-d",
"--build",
external=True,
)
case "up-recreate":
session.run(
"podman-compose", "-f", compose_file, "down", "&&",
"podman-compose",
"-f",
compose_file,
"up",
"-d",
"--force-recreate",
external=True,
)
case "down" | "stop":
session.run(
"podman-compose",
"-f",
compose_file,
"down",
external=True,
)
case _:
raise ValueError(
f"Invalid podman-compose operation: {operation}. Must be one of {valid_operations}"
)


#######################
# Repository Sessions #
Expand Down Expand Up @@ -309,4 +475,3 @@ def new_docker_template_page(session: nox.Session):
except Exception as exc:
msg = f"({type(exc)}) Error rendering template. Details: {exc}"
log.error(msg)

0 comments on commit 6c62029

Please sign in to comment.