dda-build/README.md

122 lines
5 KiB
Markdown
Raw Normal View History

2024-08-16 08:28:38 +02:00
# dda-build
[![Clojars Project](https://img.shields.io/clojars/v/org.domaindrivenarchitecture/dda-build.svg)](https://clojars.org/org.domaindrivenarchitecture/dda-build) [![pipeline status](https://gitlab.com/domaindrivenarchitecture/dda-build/badges/master/pipeline.svg)](https://gitlab.com/domaindrivenarchitecture/dda-build/-/commits/main)
2024-08-05 09:16:55 +02:00
2024-08-06 12:57:51 +02:00
[<img src="https://domaindrivenarchitecture.org/img/delta-chat.svg" width=20 alt="DeltaChat"> chat over e-mail](mailto:buero@meissa-gmbh.de?subject=community-chat) | [<img src="https://meissa.de/images/parts/contact/mastodon36_hue9b2464f10b18e134322af482b9c915e_5501_filter_14705073121015236177.png" width=20 alt="M"> meissa@social.meissa-gmbh.de](https://social.meissa-gmbh.de/@meissa) | [Blog](https://domaindrivenarchitecture.org) | [Website](https://meissa.de)
2024-08-05 09:16:55 +02:00
## Rationale
build integrates all the tools we use to work with development & clouds. We know many build tools like ant, gradle, mvn, make, leiningen or pybuilder.
But we have chosen to create & use one more due to this reasons:
2024-08-06 08:54:19 +02:00
* **No immature scripting languages**: Our builds tend to be complex. So we decided that implementing build is worth to be done in real dev-language like clojure.
* **Fast runtime**: We like runtime with simple setup & fast startup. For this reason we've chosen babashka
* **Input validation**: We believe in good input validation & good messages. For this reason we use the coole clojure-spec for build config.
* **Fast feedback**: The DevOps experience local compared to CI should be as equal as possible. We like working local for fast feedback cycles.
* **No source pollution**: All generation stuff happens in a separated build dir.
* **Tool Support**: As DevOps we are using many tools, all of them should be supported:
2024-08-05 09:16:55 +02:00
* gitops & direnv: State of environments and systems is represented by a git repo. State is applied automatically.
2024-08-06 08:54:19 +02:00
* terragrunt + opentofu: For setting up the plain infrastructure around.
* docker + podman: For creating images
* c4k-* or helm: For generating kubernetes manifests
* provs: For one-shoot setup small single-node k3s clusters and a first application.
* gopass: For credential management on devops computers
2024-08-05 09:16:55 +02:00
* cloud providers: hetzner, digitalocean or aws
## Status
Unstable
## Try out
2024-08-06 08:54:19 +02:00
We use direnv for setting the environments:
```bash
export STAGE=test
export HETZNER_API_KEY=$(gopass show path-to-hetzner-api-token)
export DO_API_KEY=$(gopass show path-to-do-api-key)
export DO_SPACES_ACCESS_ID=$(gopass show path-to-do-s3-key id)
export DO_SPACES_SECRET_KEY=$(gopass show path-to-do-s3-key secret)
export TERRAGRUNT_TFPATH=tofu
export TERRAGRUNT_DOWNLOAD=~/.terragrunt
export TERRAGRUNT_PROVIDER_CACHE=1
2024-08-05 09:16:55 +02:00
```
2024-08-06 08:54:19 +02:00
Build taske looks like this:
```clj
2024-08-05 09:16:55 +02:00
{:deps {org.clojure/spec.alpha {:mvn/version "0.4.233"}
orchestra/orchestra {:mvn/version "2021.01.01-1"}
org.domaindrivenarchitecture/build {:mvn/version "0.1.1-SNAPSHOT"}}
:tasks
2024-08-06 17:57:51 +02:00
{:init (do (def project {:name "test"
:module (first *command-line-args*)
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:debug true}))
plan
2024-08-05 09:16:55 +02:00
{:requires ([dda.build.terragrunt :as tg])
2024-08-06 17:57:51 +02:00
:task (tg/plan! project)}
2024-08-05 09:16:55 +02:00
apply
{:requires ([dda.build.terragrunt :as tg])
2024-08-06 17:57:51 +02:00
:task (tg/apply! project)}
2024-08-05 09:16:55 +02:00
destroy
{:requires ([dda.build.terragrunt :as tg])
2024-08-06 17:57:51 +02:00
:task (tg/destroy! project)}}}
2024-08-05 09:16:55 +02:00
```
2024-08-06 08:54:19 +02:00
Execute the build
```bash
bb plan [module]
```
The gitops dir layout looks like
```bash
.
├── infrastructure
│   └── tenant
│   ├── prod
│   └── test
│   ├── bb.edn
│   ├── jitsi
│   │   ├── main.tf
│   │   └── terragrunt.hcl
│   ├── statistics
│   │   ├── main.tf
│   │   └── terragrunt.hcl
│   └── terragrunt.hcl
├── modules
│   └── app
│   ├── main.tf
│   ├── registry.tf
│   ├── remote_state.tf
│   └── variables.tf
└── target
└── test
├── jitsi
│   ├── generated_backend.tf
│   ├── generated_provider.tf
│   ├── generated_registry.tf
│   ├── generated_variables.tf
│   ├── main.tf
│   └── terragrunt.hcl
└── terragrunt.hcl
```
2024-08-05 09:16:55 +02:00
## Development & mirrors
Development happens at: https://repo.prod.meissa.de/meissa/build
Mirrors are:
2024-08-16 08:28:38 +02:00
* https://codeberg.org/meissa/dda-build (Issues and PR)
* https://gitlab.com/domaindrivenarchitecture/dda-build (CI)
2024-08-05 09:16:55 +02:00
For more details about our repository model see: https://repo.prod.meissa.de/meissa/federate-your-repos
## License
Copyright © 2024 meissa GmbH
Licensed under the [Apache License, Version 2.0](LICENSE) (the "License")
Pls. find licenses of our subcomponents [here](doc/SUBCOMPONENT_LICENSE)