npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hetzner-cdk

v0.1.9

Published

Hetzner Cloud Development Kit

Downloads

19

Readme

Hetzner Cloud Development Kit

Unofficial Cloud Development Kit for Hetzner Cloud

Getting Started

.env

HETZNER_AUTH_TOKEN=xxx

index.js

const cdk = await CDK.init({
    namespace: "space",
    datacenter: DATACENTER.FALKENSTEIN,
});

const server = new Server({
    name: "spaceserver",
    image: "ubuntu-20.04",
    serverType: "cx11",
    dockerImage: "docker.io/library/httpd",
    healthCheck: {
      intervalInSeconds: 5,
      statusCode: 200,
    },
});
cdk.add(server);

cdk.run();
  • Show Diff index.js diff
  • Deploy to Hetzner Cloud index.js deploy
  • Destroy on Hetzner Cloud index.js destroy

Add SSH key to server

By default the server will create a root password that is send to you via email. It is recommended to set an SSH key to access the server.

const publicKey = PublicKey.fromFile("id_ed25519.pub");
const sshKey = new SSHKey({
    name: "spacekey",
    publicKey,
});
server.addSSHKey(sshKey);

Add IP to server

By default a server will automatically create an IPv4 address, but you will be able to attach an existing Primary IP as well.

const ipv4 = new PrimaryIP({
    name: "spaceip",
    type: "ipv4"
})
server.addPrimaryIP(ipv4)

Add Floating IP to server

By default a server will automatically create an IPv4 address, but you will be able to attach an existing Floating IP as well.

❗️ NOTE: Currently not implemented properly!

const ipv4 = new FloatingIP({
    name: "spaceip",
    type: "ipv4"
})
server.addFloatingIP(ipv4)

Options

In some cases you might want to deploy your stack to hetzner without getting the users confirmation. In that case you can append the --force option to the deploy command.

Server Configuration

By default every server will run in addition to the given docker image, an nginx proxy and the nginx proxy acme companion to issue a LetsEncrypt SSL certificate. After you deploy your server, the CDK will give you the public IP which you will need to add as an A record entry in the DNS settings of your server. The acme companion will check for that record every hour and issue the SSL certificate as soon as it is available.

Export Cloud Template

You can export the cloud configuration into a yaml template and then import it later without recreating the cloud resources. Simply define your cloud resources and then call const template = await cdk.export() instead of cdk.run(). The function will return the yaml template that you can import later with await CDK.import(template).

Private Docker Repositories

Set the following two environment variables to allow Docker pull private repositories:

HETZNER_DOCKER_USERNAME=xxx
HETZNER_DOCKER_TOKEN=xxx
HETZNER_DOCKER_REGISTRY=xxx

Examples

CDK examples can be found in the examples folder.