Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/codespaces setup #1

Merged
merged 32 commits into from
Sep 18, 2024
Merged

Feature/codespaces setup #1

merged 32 commits into from
Sep 18, 2024

Conversation

jcardozo-eth
Copy link
Member

@jcardozo-eth jcardozo-eth commented Sep 18, 2024

Overview

This pull request adds funtionality to enhance the Spring Boot Devbox Isolated Environment Demo, utilizing GitHub Codespaces. Devcontainer is configured to serve solely as an IDE, enhancing accessibility and portability for cloud-native development, without taking over dependency management which remains efficiently handled by Devbox. This setup demonstrates how Devbox and development containers can work together seamlessly, showcasing the project in a cloud-enabled environment or also running locally. The integration highlights development containers role in facilitating development online or locally using VS Code, while Devbox continues to manage all dependencies, ensuring that the environment remains robust and consistent.

Purpose and Scope of Changes

  • Clarification on Roles: The isolated shell environment is still managed by Devbox, while Devcontainer provides the option to develop and run the project in the cloud.
  • Demonstration of Hybrid Approach: Showcases the integration potential between Devbox and Codespaces, demonstrating a hybrid setup that supports consistent and efficient workflows across local and cloud environments.
  • Ephemeral URLs: Makes use of GitHub's ephemeral URLs, which provide temporary access to forwarded ports of the web server running on Codespaces.

Key Changes

  • Custom Dockerfile:

    • Base and Essential Tools: Built on Ubuntu 24.04, with essential tools like curl and ca-certificates installed, ensuring a minimal footprint by managing package installations and cleanups effectively.
    • Nix and Devbox Installation: Installs the Nix Package Manager (which is required by Devbox) in the container using Determinate Nix Installer and installs Devbox using nix.
  • Devcontainer Configuration (devcontainer.json):

    • Facilitation of Cloud-Native Development: Configures GitHub Codespaces to complement Devbox, without duplicating its functionality. Focuses on providing an optimized development environment in the cloud.
    • Port Configuration: Forwards port 8080, allowing outside access to the web server.
    • VS Code Integration: Ensures that the same devcontainer.json setup can be used to configure a consistent development environment locally within Visual Studio Code.
  • Static HTML Landing Page (index.html):

    • Introduces a new HTML page at the root URL, offering essential information, a welcome message, a link to the /greeting endpoint for API testing, and a reference to the GitHub repository for detailed project insights.
  • README.md Updates:

    • Enhanced the README.md to include detailed instructions for using GitHub Codespaces, starting the web server, and navigating the project.

Identified Issues

  • Initialization Delays: Noted longer-than-ideal initialization times for the Devbox environment setup ("devbox compute environment...").

Next Steps

  • Optimize Startup Times: Aim to enhance the startup and initialization speeds for the Devbox setup within Codespaces.
  • Security Enhancements: Continuously assess and improve security measures, particularly regarding operations under the root user within the container.

Documentation Enhancements

  • Comprehensive README.md: Revised to provide clear instructions to guide new users through using Codespaces and understanding the integration with Devbox, making the initial setup and subsequent development tasks straightforward and intuitive.

jcardozo added 30 commits September 15, 2024 23:15
Set up the development environment for the using GitHub Codespaces. This includes defining a devcontainer.json with a pre-configured universal image and necessary VS Code extensions to streamline development. The configuration automatically forwards port 8080 and sets the post-create command to start the Spring Boot server using Maven.
Devbox shell, remove extensions

Removing extensions. Changed post-create command to install Devbox, clone the git repo, change repo, enter devbox shell
This Dockerfile configures a Devbox-based development environment. It includes commands to set up necessary directories, copy configuration files, install packages, and clone the repository. Finally, it runs the Spring Boot application using Maven.
Switch from a pre-built image to building from a Dockerfile. This change allows for more customization and better alignment with project-specific dependencies. Also, update the `remoteUser` to use a dynamic environment variable.
Relocated the Dockerfile to the .devcontainer directory.
Replaces the single CMD instruction with two separate commands: one to open the devbox shell and another to run the Spring Boot application server. This enhances modularity and ensures clean execution of each step.
Changed the Dockerfile path to point to root directory to ensure the correct Dockerfile is used during the build process.
Added the DEVBOX_USER environment variable to the Dockerfile to specify the default user as 'devbox-user'. This change ensures consistency and proper configuration for user-specific operations in the container.
Create a new 'devbox-user' and set up appropriate directory permissions.
Changed the remoteUser field from a variable to a hardcoded string to ensure consistency across different development environments.
Removed unnecessary user creation and environment variable settings to reduce complexity. Preserved essential commands to maintain functionality and ensure the proper setup of the working directory and package installations. CMD at the end of the script is deleted and will be moved to devcontainer.json.
Changed the remote user from 'devbox-user' to 'devbox'. Added a post-start command to initialize the Devbox environment and run the Spring Boot application using Maven.
This commit introduces two new aliases to the devbox.json file: "start" and "stop". These scripts utilize Maven commands to manage the spring-boot application lifecycle, allowing developers to easily start and stop the application.
… run

Simplify the post-start command by replacing the existing bash script with `devbox run start`.
Updated the postCreateCommand in devcontainer.json to trigger mvn compile within the isolated environment.
- Changed the base image from Devbox to Ubuntu 24.04
- Install necessary tools (curl, ca-certificates) for a minimal setup.
- Use Determinate Systems Nix installer for secure and reliable Nix installation.
- Set up PATH to include Nix binaries.
- Install Devbox using Nix
Created a non-root user and group for better security. Updated the Dockerfile to switch to this user after installation.
Introduce a new endpoint that redirects requests from the root URL to the /greeting endpoint using RedirectView. This ensures users are automatically taken to the greeting page when accessing the root URL.
This change simplifies the Dockerfile by removing the creation of a non-root user and the subsequent user switch. This adjustment ensures that the focus remains on installing Devbox using Nix.
Add EXPOSE directive in the Dockerfile to allow the container to handle requests on port 8080. This change supports the functionality of the web server running inside the container.
Deleted the method that redirected from root endpoint to the greeting endpoint. Instead, visitors should see a landing page when accessing the base URL.
jcardozo added 2 commits September 17, 2024 12:52
Removing this command, because the web server started successfully but then exited with 0 after completion and therefore got shut down. We'll let users start the server by themselves.
Enhance README.md with detailed steps for running the project using GitHub Codespaces. Users now have an alternative option to develop and run the application directly from a cloud-based development environment.
@jcardozo-eth jcardozo-eth self-assigned this Sep 18, 2024
@jcardozo-eth jcardozo-eth merged commit d81f159 into master Sep 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant