document sops deployment
This commit is contained in:
parent
092dd2ad72
commit
b36da46543
1 changed files with 71 additions and 16 deletions
87
README.md
87
README.md
|
|
@ -279,27 +279,71 @@ Example host configuration:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
inputs.rabbi-gerzi.url = "git+ssh://git@example.com/rabbi-gerzi.git";
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
rabbi-gerzi.url = "git+ssh://git@example.com/rabbi-gerzi.git";
|
||||||
|
|
||||||
|
sops-nix = {
|
||||||
|
url = "github:Mic92/sops-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ nixpkgs, rabbi-gerzi, ... }:
|
{
|
||||||
|
nixpkgs,
|
||||||
|
rabbi-gerzi,
|
||||||
|
sops-nix,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
nixosConfigurations.rabbigerzi = nixpkgs.lib.nixosSystem {
|
nixosConfigurations.rabbigerzi = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
rabbi-gerzi.nixosModules.default
|
rabbi-gerzi.nixosModules.default
|
||||||
{
|
sops-nix.nixosModules.sops
|
||||||
services.rabbi-gerzi = {
|
(
|
||||||
enable = true;
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
appKey = config.sops.placeholder."app-key";
|
||||||
|
initialAdminEmail =
|
||||||
|
config.sops.placeholder."admin-email";
|
||||||
|
initialAdminPassword =
|
||||||
|
config.sops.placeholder."admin-password";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
sops = {
|
||||||
|
defaultSopsFile = ./secrets/rabbi-gerzi.yaml;
|
||||||
|
age.sshKeyPaths = [
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key"
|
||||||
|
];
|
||||||
|
|
||||||
frontend.hostName = "rabbigerzi.com";
|
secrets = {
|
||||||
|
"app-key" = { };
|
||||||
|
"admin-email" = { };
|
||||||
|
"admin-password" = { };
|
||||||
|
};
|
||||||
|
|
||||||
backend = {
|
templates."rabbi-gerzi.env".content = ''
|
||||||
hostName = "api.rabbigerzi.com";
|
APP_KEY=${appKey}
|
||||||
environmentFile = "/run/secrets/rabbi-gerzi.env";
|
RABBI_GERZI_INITIAL_ADMIN_EMAIL=${initialAdminEmail}
|
||||||
|
RABBI_GERZI_INITIAL_ADMIN_PASSWORD=${initialAdminPassword}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
services.rabbi-gerzi = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
frontend.hostName = "rabbigerzi.com";
|
||||||
|
|
||||||
|
backend = {
|
||||||
|
hostName = "api.rabbigerzi.com";
|
||||||
|
environmentFile =
|
||||||
|
config.sops.templates."rabbi-gerzi.env".path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -313,14 +357,25 @@ services.rabbi-gerzi.frontend.apiBaseUrl =
|
||||||
"https://api.rabbigerzi.com";
|
"https://api.rabbigerzi.com";
|
||||||
```
|
```
|
||||||
|
|
||||||
Create the production environment file on the server:
|
Configure `.sops.yaml` with age recipients for each administrator and the
|
||||||
|
server's SSH Ed25519 host key. Then create the encrypted secrets file:
|
||||||
|
|
||||||
```dotenv
|
```sh
|
||||||
APP_KEY=base64:replace-with-laravel-app-key
|
sops secrets/rabbi-gerzi.yaml
|
||||||
RABBI_GERZI_INITIAL_ADMIN_EMAIL=admin@example.com
|
|
||||||
RABBI_GERZI_INITIAL_ADMIN_PASSWORD=replace-with-a-long-random-password
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Add these values in the editor opened by `sops`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
app-key: base64:replace-with-laravel-app-key
|
||||||
|
admin-email: admin@example.com
|
||||||
|
admin-password: replace-with-a-long-random-password
|
||||||
|
```
|
||||||
|
|
||||||
|
Commit only the encrypted file written by `sops`. At activation time,
|
||||||
|
`sops-nix` decrypts these values and renders the runtime environment file
|
||||||
|
outside the Nix store.
|
||||||
|
|
||||||
Then rebuild the host with the deployment method used by the server, for
|
Then rebuild the host with the deployment method used by the server, for
|
||||||
example:
|
example:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue