Streamlining DevOps with Earthly and Daytona
Tags: guides
Published: 2024-01-23 10:54:14

---
title: Streamlining DevOps with Earthly and Daytona
published: true
date: 2023-12-22 00:00:00 UTC
tags: Guides
canonical_url: https://www.daytona.io/dotfiles/streamlining-devops-with-earthly-and-daytona
---
![Streamlining DevOps with Earthly and Daytona](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/375tpw6dm6smt76325z2.jpeg)

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.

 ![](https://www.datocms-assets.com/103916/1703255631-earthly-snapshot.png)
## 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.

 ![](https://www.datocms-assets.com/103916/1703255636-earthly-platform.png)
## 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.

 ![](https://www.datocms-assets.com/103916/1703255641-earthly-file.png)
## 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.

 ![](https://www.datocms-assets.com/103916/1703255603-earthly-devcontainer.png)
## 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.

 ![](https://www.datocms-assets.com/103916/1703255621-earthly-build.png)
## 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](https://github.com/metcalfc/snapshot-base). Additionally, to see these steps in action, you can view the [full video tutorial on YouTube](https://www.youtube.com/watch?v=zQ5XbnSnhn4), 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.