Skip to main content
Version: 1.26

Build your container images with Okteto

The Movies app is using pre-built images to deploy your Development Environment. In this step you will use Okteto to build these images on demand in order to deploy the latest bits of your application.

To instruct Okteto to build your images, add the following content to the okteto.yaml file:

okteto.yaml
build:
api:
context: api
frontend:
context: frontend

The build context for the api image is in the api folder and Okteto will build the api image using the api/Dockerfile. The frontend images work in a similar way. Now you can build your images with okteto build:

okteto build
 i  Using cindy @ okteto.example.com as context
i Building 'api/Dockerfile' in tcp://buildkit.okteto.example.com:443...
...
✓ Image 'registry.okteto.example.com/cindy/movies-with-helm-api:okteto' successfully pushed
i Building 'frontend/Dockerfile' in tcp://buildkit.okteto.example.com:443...
...
✓ Image 'registry.okteto.example.com/cindy/movies-with-helm-frontend:okteto' successfully pushed

Finally, update your deploy section in your okteto.yaml file to use these images in the helm installation. To do that, use the OKTETO_BUILD_<<image-name>>_IMAGE environment variables to access to the dynamic tag generated by Okteto for your container images:

note

Read more about Okteto's built-in environment variables for images

okteto.yaml
deploy:
- name: Helm Install
command: |
helm upgrade --install movies chart \
--set api.image=${OKTETO_BUILD_API_IMAGE} \
--set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}

Deploy the Movies app to apply the changes:

okteto deploy
 i  Using cindy @ okteto.example.com as context
i Deploying dependency 'mongodb'
✓ Skipping repository 'mongodb' because it's already deployed
i Okteto Smart Builds is skipping build of 'api' because it's already built from cache.
i Okteto Smart Builds is skipping build of 'frontend' because it's already built from cache.
i Okteto recommends that you enable remote execution for your deploy commands.
i Running 'Helm Install'
Release "movies" does not exist. Installing it now.
NAME: movies
LAST DEPLOYED: Fri Jan 19 23:54:00 2024
NAMESPACE: cindy
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
Success! Your application will be available shortly.
i Endpoints available:
- https://movies-cindy.okteto.example.com
- https://movies-cindy.okteto.example.com/api
✓ Development environment 'movies' successfully deployed

Next Steps

Congratulations! You successfully deployed your first application to Okteto 🚀

Now, here’s what you can explore next: