Skip to main content
Version: 1.4

Development Environments

One of the advantages of using Okteto is the ability to configure development environments as code, side by side with your application.

Instead of having to keep a wiki with a never-ending list of tools, dependencies, and scripts to install and run, you just have to clone your repository, deploy your application, and run okteto up to start developing in seconds.

Before you get started

Setting up development environments using Okteto involves two main steps:

  1. Deploying your application code
  2. Using okteto up to start your development container

For using okteto up, you will need to install the Okteto CLI. Okteto CLI is an open-source tool that helps spin up development containers regardless of where you choose to deploy your application code as part of the first step. You can learn more about it by heading to the documentation here.

Coming to the first step of deploying your application code, there are multiple options available for you to choose from. You can choose to deploy it on an existing cluster and use Okteto CLI to interact with this cluster.

A second option available is Okteto Cloud. Using Okteto Cloud, you don't have to take care of setting up the infrastructure for deployment yourself. Okteto Cloud was built keeping dev environments in mind, so it also comes with useful additional features you would not find in a traditional cluster. To know more about it, you can head over to the Okteto Cloud documentation.

Another option available is Okteto Self-Hosted. Okteto Self-Hosted gives you all the features of Okteto Cloud - on your own infrastructure. This offers you full control of your Kubernetes infrastructure while delivering the same smooth experience you expect from Okteto Cloud. The Okteto Self-Hosted documentation covers how you can get started with it.

Getting started

At a high level, a development container is a Docker container that contains:

  • One or more language runtimes (e.g python, ruby, node)
  • SDKs for your language runtime (e.g JDK, python-dev)
  • Binary dependencies (e.g. openssl, git)
  • Tools to manage and install dependencies (e.g. pip, bundler, yarn)
  • Tools to run your tests and analyze your code (e.g nosetest, pylint)
  • Your source code

When you run the okteto init command on a local repository, okteto will analyze your source code and will guess the main programming language you're using. Based on this, it will select a base development container configuration and create a default okteto.yml for you.

For example, if your repository is mostly golang, it will look like this:

dev:
my-app:
image: golang:alpine
volumes:
- /go/pkg/
- /root/.cache/go-build/
forward:
- 8080:8080

Out of the box, Okteto maintains pre-configured development images in this GitHub repository for the following languages:

  • dotnetcore
  • golang
  • java
  • node
  • php
  • python
  • ruby
  • rust

Create your own

The default development images are a great way to start. They use the latest official docker image for your language runtime and include the most common developer tools and a custom bash prompt. But they might not have everything you need. Your team might need to support a very specific version of your runtime, or you might need some extra tooling available.

Do the following to create your own development image:

  1. Create a Dockerfile
  2. Pick a base image
  3. Add your extra dependencies, tools, and files
  4. Build your image, tag it, and push it to your docker registry
  5. Update the image key in your okteto.yml with your new image

Besides following Docker's best practices, we also recommend the following:

  • Create the docker image in CI, so it's clear how and when it was built
  • Pin all your dependencies, so there aren't any surprises
  • Keep the Dockerfile in your repository, next to your code
  • When using multi-stage builds, use your development image as the builder stage, so that you have the same tools and images in dev than in CI/CD