Code Monkey home page Code Monkey logo

packer-provisioner-deno's Introduction

packer-provisioner-deno

Run Deno scripts to provision stuff with Packer.

This plugin installs deno on the target machine, runs deno bundle locally, uploads the bundled scripts onto the target machine, and executes them.

Installation

This provisioner is a Packer plugin. See the docs for an overview.

Build or download this plugin and place in

$HOME/.packer.d/plugins

You may need to create the plugins directory.

Provisioner Configuration

You must specify "type": "deno" in a provisioners stanza to use this plugin.

The following provisioner config keys are supported. See also the examples directory.

  • local_deno_bin (string) - A fully qualified path to a local deno executable. This binary will be used for local bundling and uploaded to the target remote_folder. Useful if you are building deno from source. Other version specifiers ignored.
  • target_deno_version (string) - a version passed to the deno installer script. Must match a git tag from deno's releases.
  • remote_folder (string) - The target directory where scripts will be uploaded.
  • skip_install (boolean) - If true, do not install Deno on the target machine, but assume it is already present.
  • scripts (array of string) - A list of paths to TypeScript files that will be passed to deno run -A, one by one, in order. These are your provisioning scripts. Currently, these must be standalone scripts with no path-based dependencies.

Development and Tests

You will need Go 1.13 or later. $GOPATH/bin should be on your PATH.

If you want to hack, make a symlink from $GOPATH/bin/packer-provisioner-deno to the packer plugins directory. Something like this should work, after an initial go install:

ln -s $GOPATH/bin/packer-provisioner-deno $HOME/.packer.d/plugins/packer-provisioner-deno

After that, run the test script

./test.sh

A test build will run in a Docker container.

TODO

We want to accomplish the following

  • Install deno onto target system
  • Upload individual deno scripts
  • Execute individual deno scripts as root
  • Add a DigitalOcean cloud builder test
  • Allow uploading local deno builds easily (for testing local dev builds)
  • Manually bundle scripts locally and upload those.
  • Execute scripts as non-root user
  • Specify sandboxing flags in the packer config (--allow-net and friends; we run with -A right now)
  • Global system install of deno outside any user's HOME
  • Add a Vagrant builder test
  • Specify alternative install command (for test deno builds fetchable from network)

packer-provisioner-deno's People

Contributors

anxiousmodernman avatar dontlaugh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

packer-provisioner-deno's Issues

Platform test for curl-to-shell install method

Deno usually needs to be delivered to the target platform. We can do this with:

  • uploading a local build (uncommon, probably for Deno devs only) with local_deno_bin
  • curl-to-shelling the installer script

The latter method means we need to test for curl on the system, and if it isn't present, install it. If the system has a package manager, it's likely that curl will be there.

Let's try to stick to the standard installer script, and if we find a bug in it on a specific platform, contribute the change upstream (if it's not too esoteric and complex).

Allow specifying version to install

Since we bundle scripts locally, then upload and execute them remotedly (#4), there is a chance that a version mismatch can cause execution to fail.

The deno installer script allows specifying a version

curl -fsSL https://deno.land/x/install/install.sh | sh -s v0.27.0

We add a config parameter that allows specifyng this during installation.

We might also consider parsing the output of deno --version locally, and automatically trying to match it up.

Provisioning step hangs

There is a known issue with compiling TypeScript code (aka your deno scripts) on machines that only have a single CPU denoland/deno#2124

For your cloud provider's builder stanza, work around this by selecting an image size with at least 2 CPU/vCPU.

$ doctl compute size list

On digitalocean, the cheapest droplet with 2 CPUs is $15/mo and has slug identifier s-2vcpu-2gb.

Upload and execute bundles

Bundling support is almost here. Test it out and upload bundles into virtual machines and containers for bigger, more complex provisioning use cases.

The idea here is to avoid fetching and compiling code on the target machine, so we will require (by default), a local deno installation. This will speed up repeated packer builds since unchanged bundles could be cached and uploaded right away (instead of fetching/recompiling every time on the clean target environment).

We should, of course, allow overriding this behavior so that deno on the target machine can fetch and compile code. Not everyone who runs packer will want or be able to install Deno locally. But I think the common case will benefit from local compilation.

Besides, I want to figure out the whole ship-compiled-code thing ;-)

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.