# Contents

This guide will walk you through creating a Docker environment using Earthly and DevContainer. We'll begin by setting up a Docker file to utilize Ubuntu's snapshot repositories, then explore how to build images for different architectures. Finally, we'll integrate Earthly for streamlined builds and testing, and set up a development container for a complete development environment.

Utilizing Ubuntu Snapshot Repositories

  1. Open your Daytona workspace.

  2. Create a Docker file to access Ubuntu snapshot repositories, which allow you to use a specific snapshot of Ubuntu packages from a certain date.

  3. Define the snapshot date in the config.toml file. For example, set it to November 5, 2023.

  4. In your Docker file, instruct it to fetch packages from the Ubuntu snapshot as of the specified date and update the sources list accordingly.

Streamlining DevOps with Earthly and Daytona
Streamlining DevOps with Earthly and Daytona

Building for Multiple Architectures

  1. To support both x86 and ARM architectures, use Docker's buildx feature.

  2. Execute the Docker buildx command, specifying platforms for AMD and ARM.

  3. Incorporate variables into the build process to manage different configurations.

Streamlining DevOps with Earthly and Daytona
Streamlining DevOps with Earthly and Daytona

Simplifying with Earthly

  1. Instead of separate Docker and make files, combine your configuration into one Earthly file.

  2. Set global variables for the build date and snapshot in the Earthly file.

  3. Use the Earthly file to build your Docker target and add a simple smoke test to verify package installation.

Streamlining DevOps with Earthly and Daytona
Streamlining DevOps with Earthly and Daytona

Setting Up DevContainer

  1. Start with an Ubuntu Jammy base for your DevContainer.

  2. Configure environment variables to pass GitHub credentials and set up Docker and Earthly.

  3. Ensure the DevContainer includes necessary extensions for make, Docker, and Earthly.

  4. Automate login to GitHub registry upon starting the DevContainer.

Streamlining DevOps with Earthly and Daytona
Streamlining DevOps with Earthly and Daytona

Testing and Building with Earthly

  1. Verify Earthly installation by running a test command.

  2. Observe Earthly's build process, which includes pulling the base image and updating package lists.

  3. Push the completed build to your repositories using the Earthly push command.

Streamlining DevOps with Earthly and Daytona
Streamlining DevOps with Earthly and Daytona

Advantages of Using Earthly

  • Earthly caches your builds, making subsequent builds faster.

  • A single Earthly file simplifies the build and test process.

  • Integration with DevContainer provides a ready-to-use development environment with all necessary tools installed.

Code and Full Tutorial on YouTube

For those interested in exploring the code and configurations discussed in this guide, the Git repository is available at https://github.com/metcalfc/snapshot-base. Additionally, to see these steps in action, you can view the full video tutorial on YouTube, which provides a comprehensive walkthrough of the entire process.

Conclusion

By following these steps, you can set up a Docker environment that leverages the power of Earthly and DevContainer. This setup allows for efficient management of Docker builds, streamlined testing, and a fully equipped development container, ensuring a smooth and productive workflow.