Skip to content

AlahmadiQ8/coda-pack-local-dev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local Coda Pack Development with Docker Containers

TLDR: Install docker, install VSCode, install Remote - Containers Extension, clone this template, open vscode command pallete and run Reopen in Container, open bash terminal in VSCode and run npx coda init.



Background

For large coda packs, developing locally is more productive than using Coda Pack Studio. Straight out of Coda SDK Docs, here are some benefits:

  • You can use your own code editing tools, such as Visual Studio Code.
  • You can use your own version control system, such as GitHub.
  • You can use popular JavaScript libraries1, such as those in NPM.
  • Instant feedback loop for testing your code. Just npx coda execute ... to test your pack blocks.

Unfortunately, setting up local development environment for Coda SDK is not as easy as just having NodeJs and npm installed. but you also need to install isolated-vm which already has its own requirements. Instructions also differ whether you are on Windows, MacOs, or Linux.

Now you can get started with local development within 5 minutes regardless of your platform. All you need is to have Docker and VSCode installed.

How it works

VSCode allows you to open any folder inside (or mounted into) a docker container and take advantage of Visual Studio Code's full feature set. A devcontainer.json file tells VS Code how to access (or create) a development container with a well-defined tool and runtime stack.

This template is almost exact copy of the container configurations generated from the VSCode Remote - Containers Extension. There are only a couple of line changes. See start from scratch option

More information information, checkout the full documentation: https://code.visualstudio.com/docs/remote/containers.

Prerequisites

Setup

There are two options to setup. Either just use this template, or start from scratch by generating the .devcontainer congiruations yourself via Add Development Container Configuration Files... command and making some changes.

The benefit of the first option is that we might add more custom configratutions in the future where all you need to do is just clone the template and start developing immediately.

Option 1: Use this Template

1 - Clone the template

Click on Use this template as shown below:

2 - Open template directory in a VSCode workspace

Open a new VSCode workspace for the template repository you just cloned. VSCode will prompt you to reopn the workspace in a docker container as shown below:

Click on Reopen in Container. This will do the following:

  1. Build a docker image based on the dockerfile inside .devcontainer folder
  2. Launch a docker container using the docker image
  3. Reopens VSCode inside the container

Option 2: Start from scratch

Open a new blank workspace. Run the following command to add .devcontainer configurations for Noejs environment.

gif-record-2

In the .devcontainer.json, make sure you setup port forwarding:

  //  ...
	"forwardPorts": [3000],
  // ...

In the Dockerfile add the following line at the end

RUN su node -c "npm install -g @codahq/packs-sdk"

Initialize new coda pack project

About

A template to intantly start developing coda packs locally with docker

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Contributors