Skip to content

meatcar/deploy.denys.me

Repository files navigation

Infrastructure for denys.me

built with nix

Requirements

  • direnv
  • nix or nixos

If nix is not available, you can try to make do with:

  • packer

  • terraform with terraform-provider-secret

  • A nixos image for Digital Ocean, you can try to make one with packer and nix-infect as follows:

    packer build packer/build-image.json

    Then manually make a snapshot of it in the Digital Ocean console.

Building a Base Image

# Build an image
IMAGE=$(nixos-generate -f do -c nix/base.nix)
# Push the image to Digital Ocean
packer build -var image=$IMAGE packer/push-image.json

Running

If you've never run this before, you need to create some AWS resources to store the terraform state. We choose to store the state in the cloud to improve locking, and persist it between machines.

# make sure you have aws credentials in ~/.aws
cd terraform/tf-modules/terraform-state
terraform init
terraform apply

Now, you can run the rest of the deployment.

cp .env.example .env
$EDITOR .env # see variables.tf for advice on how to get certain vars
cd terraform
terraform init
terraform apply