Skip to main content

Simplify Your Codehooks Development with Devcontainers

· 3 min read
Martin

In this blog post, we'll show you how to set up and use a devcontainer for Codehooks development. Devcontainers, a feature of Visual Studio Code, allow you to create a consistent development environment that can be shared across your team, streamlining your workflow and reducing setup time. Developers on OS X, Windows and Linux will now get the same environment with everything set up correctly from the start.

Codehooks is a powerful Backend-as-a-Service platform that provides Express-like endpoints, a NoSQL document database, a key-value store, a worker queue system, and a CRON-like job scheduling system, all managed through a simple CLI. To set up a devcontainer for Codehooks, follow the steps outlined in this article.

socialcard

Step 1: Install Prerequisites

Before starting, ensure you have the following installed on your system:

  • Visual Studio Code
  • Docker
  • Dev Containers extension for Visual Studio Code

Step 2: Create a New Project

Create a new folder for your project and open it in Visual Studio Code.

Step 3: Add Devcontainer Configuration Files

Press F1 to open the command palette, type "Dev Containers: Add Dev Container Configuration Files..." and press Enter. Choose a base container like "Node.js" to start with.

Step 4: Configure the Devcontainer

In the newly created .devcontainer folder, open the devcontainer.json file and add the necessary configurations:

// See https://containers.dev/implementors/json_reference/ for configuration reference
{
"name": "Codehooks Devcontainer",
"build": {
"dockerfile": "Dockerfile"
},
"remoteUser": "node",
"forwardPorts": [3000],
"postCreateCommand": "sudo npm install -g codehooks"
}

This configuration installs the required extensions, forwards port 3000, and installs the Codehooks CLI globally after the container is created.

Step 5: Build and Run the Devcontainer

Close the current window, and reopen the project folder. Visual Studio Code should prompt you to reopen the folder in the container. Click "Reopen in Container."

Step 6: Use the Codehooks CLI

After the container is built and running, open the terminal in Visual Studio Code. You can now use the Codehooks CLI to manage your project. You can now go to the 'Quick start' to start developing with codehooks.io (and you can skip the first step where you install the CLI 🤠)

Conclusion

With this setup, you can develop your application using the Codehooks platform within the devcontainer environment. The extensions, port forwarding, and post-create command specified in the devcontainer.json file help to create a seamless development experience. Devcontainers provide a consistent and efficient way to streamline your Codehooks development workflow, making it easier to collaborate with your team and manage your projects.

There is a lot more you can do with devcontainers. We have only created one of the simplest setups you can have. Check out containers.dev to learn more.