Code Monkey home page Code Monkey logo

tevbox's Introduction

tevbox

Technat's Development Box in the cloud.

Goal

I'm tired of unpredictable development environments that are bound to your local hardware. While there are many solutions out there for this and similar problems, I prefer to setup my own. This has multiple reasons:

  • performance of container-based IDEs is often rather poor or insufficient (for running local dev instances of things)
  • container based IDEs are not persistent, which is sometimes nice to have (e.g if you spin uf local Kubernetes clusters and want them to run a couple of hours)
  • control of the network stack is often not given (e.g no public IP or direct access to services exposed on your machine)
  • they usually stop working when you are inactive for some time (e.g they are session-based, not running in the background)
  • you have no idea what's all running on your IDE machine nor could one call the image minimal

Of course the solutions I'm talking about are usually way better integrated than everything you could possibly engineer yourself, but I still do have my own solution how I can create a fresh cloud server ready to code and tinker on.

Solution design

In general: a tevbox is just a dead-simple VPS with Ubuntu Server as OS and some development tools including the awesome code-server that provides the IDE experience in a browser. In my case I'm using Hetzner as cloud-provider as their machines offer great performance for value.

The workflow for creating a new VM should look like this: I click on the Actions for this repo, click "Create new box", enter some details and the box is created within minutes (faster is always appreciated), spilling out an URL that opens code-server for me.

The design makes use of the following Tools:

Apart from these tools, I also use Github for the code and actions and Hetzner for the servers. The workflow shouldn't make use of any other services to keep dependencies minimal.

Tech Details

Using Github Actions as automation gives you certain benefits:

  • directly integrated into Github, a click away from the source-code
  • you don't need any extra login or account
  • github actions can dispatch workflows manually, giving the user the option to enter some parameters

There are two main actions I will eventually merge into one:

  • deploy.yml: Creates a new tevbox via Terraform
  • destroy.yml: Deletes an existing tevbox via Terraform

For both actions to know about servers that exist, they put their Terraform state on S3. Currently Amazon S3 is used for this job, but once Hetzner releases their S3 implementation, we will switch to that. Using the name of a tevbox as identifier for the state means, that you can delete a box by simply entering the tevbox's name and thus pointing the workflow to the right Terraform state file to use.

Terraform itself creates the VM and any necessary cloud-resources. Cloud-init is responsible for configuring the server at first boot. This is done using a simple shell script and some templating. Initially this project used Ansible for that job in pull-mode, but since that was too slow and without any benefits for a one-shot configuration we switched to something simpler.

Once I have a box to use, some things nice things to know are:

  • tevbox is based on Ubuntu Server (we removed multi-OS support again as it was never really used and took too much effort to maintain)
  • tevbox is multi-arch compatible, arm64 and amd64 are available (defined by the used instance type)
  • the code-server listens on 127.0.0.1:65000
  • the code-server is exposed using Caddy that binds to 0.0.0.0:80 and 0.0.0.0:443
  • Cloning Github repositories is best done using HTTPS as code-server can automatically authenticate you against Github using device codes
  • Expose dev services on localhost and access them on the internet using <port>.<tevbox_name>.technat.dev (or whatever your zone is).

In case of a failure in the cloud-init script, the only way to get access to the server is using the Console in the portal. Use the root user and the password sent to you via mail (if you haven´t deleted that mail already).

Preconditions

For the tevbox project to work, it's important to have some static things:

  • A Hetzner project with:
    • the account-nuker installed
    • A cost limit + notification
    • An API Token for the project that is allowed to read & write (token is only used within github actions)
  • A DNS zone hosted on Hetzner DNS
    • A DNS API Token (token is used within github actions and also shared with tevboxes to grab a DNS-01 challenge-based wildcard certificate)
  • An S3 bucket for the Terraform state (for AWS this includes an IAM policy & role and OpenID provider for Github Actions to authenticate)
  • This repo holding the source-code

tevbox's People

Contributors

renovate[bot] avatar the-technat avatar

Watchers

 avatar

tevbox's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/checks.yml
  • actions/checkout v4
  • hashicorp/setup-terraform v3
  • aws-actions/configure-aws-credentials v4
.github/workflows/deploy.yml
  • actions/checkout v4
  • aws-actions/configure-aws-credentials v4
  • hashicorp/setup-terraform v3
.github/workflows/destroy.yml
  • actions/checkout v4
  • aws-actions/configure-aws-credentials v4
  • hashicorp/setup-terraform v3
terraform
tevbox.tf
  • hcloud 1.48.0
  • hetznerdns 2.2.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.