Building recipes

June 3, 2016

Spacedecode offers two different options you could follow to create your own recipes. Each of these methods have their own use-cases and you just have to pick one that works for you at that time:

  • Spacedfile: You can build recipes by writing a Spacedfile and using the spaced recipe build command;
  • Snapshotting: You can snapshot the current state of a vessel into a new recipe;

Spacedfile

To build a recipe from a Spacedfile, you have to run the build command in this form:

$ spaced recipe build /context/path -f /path/to/your/Spacedfile -n name -s namespace

Let’s break this command down:

spaced recipe build

This is a spacedecode command that accepts all the required properties and send them to the Spacedecode daemon for processing. The command itself does not handle the build process, it just prepares the requests and listens for output.

/context/path

This option (a directory) provides additional data to the build process. For example you may have some bash scripts you want to use inside your recipe or even binary files you want to import into the recipe. If you don’t need a context, just pass -. If your context is the current directory, use ..

Note! The build command will upload the whole context directory to the Spacedecode daemon for further processing. So, be careful what you put in that director. If you use / for example, the contents of your entire hard-drive will be uploaded to the daemon.

-f /path/to/your/Spacedfile

This options tells the build process where to find your Spacedfile. If the Spacedfile is in the context, you can skip this options and Spacedecode will look inside the context for a file names Spacedfile or Dockerfile.

-n name and -s namespace

Together, these parameters form a recipe reference in the form namespace/name. An optional parameter -t (or --tag) can be specified to label the version of the recipe. With the tag, the recipe reference would look something like this namespace/name:tag.

Note! If --namespace / -s is not provided, Spacedecode will use the username of the logged in user.

Example:

Consider the following example Spacedfile (see Spacedfile for details on available Spacedfile instructions):

FROM debian:wheezy

RUN \
  apt-get update -qq && \
  apt-get install -qq -y python python-dev python-pip python-virtualenv && \
  rm -rf /var/lib/apt/lists/*
  
CMD ["bash"]

I can build recipe from this file using the following command:

$ spaced recipe build - -f Spacedfile -n python -s sithembiso

You should see the following output (or similar):

Uploading context to the SpaceD daemon: 307 B
Parsing Spacedfile...

Step 1: FROM debian:wheezy

Step 2: RUN    apt-get update -qq &&    apt-get install -qq -y python python-dev python-pip python-virtualenv &&    rm -rf /var/lib/apt/lists/*
...
Setting up libalgorithm-diff-xs-perl (0.04-2+b1) ...
Setting up libalgorithm-merge-perl (0.08-2) ...
Setting up libfile-fcntllock-perl (0.14-2) ...
 ----> 7647174b37dfe3520d00d4e7164f6571

Step 3: CMD ["bash"]
 ----> 72942d7ceb22588ff128fa34877d4bf7
Generating recipe...

Cleaning up...
Build was completed successfully

The next time you view the recipe list, you should have a new recipe that you can use straight away.

Snapshotting

This process is much simpler because at the point of snapshotting, a lot of work would have been done already. In short, snapshotting allows you to create a recipe from the current state of a vessel.

Imagine you have a vessel awesome.vsl and you have done a lot of work on it in terms of setting up. Snapshotting this vessel for future use here may be a great idea. All you need to do this is the vessel ID (simply run spaced vessel list to find the ID).

Once you have that, just run this command:

$ spaced vessel snapshot <vessel_id> -n name -s namespace

Breaking the command down:

spaced vessel snapshot

This is a Spacedecode command that sends snapshotting parameters to the Spacedecode daemon.

<vessel_id>

Vessel unique identifier.

-n name and -s namespace

Together, these parameters form a recipe reference in the form namespace/name. An optional parameter -t (or --tag) can be specified to label the version of the recipe. With the tag, the recipe reference would look something like this namespace/name:tag.



comments powered by Disqus