From df7a4432e85a89b54268cdd91f1230fe39c69179 Mon Sep 17 00:00:00 2001 From: oreoluwa212 Date: Tue, 26 Nov 2024 03:27:46 +0100 Subject: [PATCH] fix: hot fix for tips to effectively use srcbook in daytona env --- guides/20240910_guide_srcbook.md | 78 +++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/guides/20240910_guide_srcbook.md b/guides/20240910_guide_srcbook.md index daacc35a..e5f93b19 100644 --- a/guides/20240910_guide_srcbook.md +++ b/guides/20240910_guide_srcbook.md @@ -29,10 +29,12 @@ Before getting started, ensure you have the following prerequisites: ### Example Preparations - **Step 1.1**: Install Docker and verify it's running. - ```bash - docker --version - ``` - Confirm Docker is installed by running the above command. The output should display the Docker version. + + ```bash + docker --version + ``` + + Confirm Docker is installed by running the above command. The output should display the Docker version. - **Step 1.2**: Install Daytona and ensure that Daytona is properly installed by verifying the `daytona` command is recognized. @@ -45,19 +47,21 @@ This section covers creating a starter repository, setting up a `devcontainer.js 1. **Create a GitHub Repository**: Start by creating a new GitHub repository for your Srcbook project. 2. **Clone the Repository** to your local machine: ```bash - git clone https://github.com/your-username/srcbook-project.git + git clone https://github.com//srcbook-project.git cd srcbook-project ``` ### Step 2.2: Setting Up the `devcontainer.json` File In the root of your repository, create a `.devcontainer` directory and add the `devcontainer.json` file: + ```bash mkdir .devcontainer touch .devcontainer/devcontainer.json ``` Now, open the `devcontainer.json` file and add the following configuration: + ```json { "name": "Srcbook Development", @@ -67,9 +71,10 @@ Now, open the `devcontainer.json` file and add the following configuration: "forwardPorts": [2150] } ``` + - **Note:** -- *Post Commands*: Automatically install necessary packages and start Srcbook after the container is created. -- *Forward Ports*: Ensures Srcbook runs on `localhost:2150` as specified in the devcontainer.json file. +- _Post Commands_: Automatically install necessary packages and start Srcbook after the container is created. +- _Forward Ports_: Ensures Srcbook runs on `localhost:2150` as specified in the devcontainer.json file. ### Step 2.3: Launching the Devcontainer and Daytona @@ -82,15 +87,16 @@ Now, open the `devcontainer.json` file and add the following configuration: ``` Daytona will now be ready to manage the Srcbook project. - ### Step 2.4: Creating a New Srcbook Project With Daytona running and the environment set up, you can now create a repository with a devcontainer for Srcbook: # Example + ```bash daytona create https://github.com/oreoluwa212/srcbooks-devcontainer ``` + ![Daytona Setup Screenshot](../articles/assets/20241110_srcbook_create.png) This command will generate a new TypeScript notebook for interactive coding. @@ -98,21 +104,60 @@ This command will generate a new TypeScript notebook for interactive coding. ### Step 2.5: Running Srcbook Once your interactive TypeScript notebook environment, you can proceed to open with your preferred IDE following this [daytona IDE docs](https://www.daytona.io/docs/usage/ide) -![Daytona Setup Screenshot](../articles/assets/20241110_srcbook_running.png) - +![Daytona Setup Screenshot](../articles/assets/20241110_srcbook_running.png) ## Step 3: Confirmation To confirm that your setup is correct, ensure the following: + - Docker engine is up and running. - Daytona server is running, and you can check status at `localhost:3986/health` - Your interactive notebook is up and ready for use. **Tip**: If you see any errors, review your `devcontainer.json` for misconfigurations, or restart Daytona using: + ```bash daytona serve ``` +## Step 4: Running Srcbook Project + +### 4.1 Access Methods + +- Open via Daytona web interface +- Use VSCode Remote Containers extension +- Access through forwarded port `localhost:2150` + +### 4.2 First Notebook + +Create a sample TypeScript notebook to verify setup: + +```typescript +const greet = (name: string) => `Hello, ${name}!`; +console.log(greet("Srcbook")); +``` + +## Step 5: Tips for Effective Use + +### 5.1 Environment Management + +- Always use `.devcontainer.json` for consistent setups +- Commit and push notebook changes regularly to preserve your interactive coding progress +- Use environment variables for configuration, Use lock files (`package-lock.json` or `yarn.lock`) to ensure consistent environments +- Understand that Srcbook notebooks maintain state between cells, use this to create sequential, context-aware computational workflows +- Be mindful of memory usage in long-running notebooks, use `delete` or reassign large variables to free up memory + +### 5.2 Workspace Best Practices + +- Commit `devcontainer.json` to version control +- Use console.log() and breakpoints effectively in Srcbook +- Document any specific configuration or setup steps in a `README` +- Use Daytona's workspace management for team consistency +- Use GitHub Actions or similar tools to validate notebook execution +- Export notebook results as part of your documentation or reporting process + +### 5.3 Troubleshooting + ## Common Issues and Troubleshooting ### Problem 1: Container Fails to Start @@ -122,21 +167,30 @@ daytona serve ### Problem 2: Daytona Unable to Connect **Solution**: Check that Daytona is running correctly by using: + ```bash daytona +# Check Daytona workspace status +daytona list + +# Restart workspace +daytona restart + +# View workspace logs +daytona logs ``` ## Conclusion -By following this guide, you’ve successfully integrated Srcbook with Daytona, creating an efficient cloud-based TypeScript notebook environment. This setup allows for seamless interactive coding, project management, and environment control. +By following this guide, you’ve successfully integrated Srcbook with Daytona, creating an efficient cloud-based TypeScript notebook environment. This guide demonstrated how to integrate Srcbook with Daytona, creating a powerful, reproducible TypeScript notebook development environment. By following these steps, you can streamline your development workflow and ensure consistent, shareable coding experiences. Explore more advanced Srcbook features by visiting the [Srcbook Documentation](https://srcbook.com) and continue to refine your Daytona setup by reading through the [Daytona Documentation](https://www.daytona.io/docs). - ## References - [Srcbook GitHub Repository](https://github.com/srcbookdev/srcbook) - [Srcbook Website](https://srcbook.com) - [Daytona Documentation](https://www.daytona.io/docs) +- [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/) --- \ No newline at end of file