Build an Image with the Dockerfile in Root Directory
Get started quickly with building Docker images
Building a Docker image is one of the basic operations in Codefresh pipelines.
The source code of the repository is located at https://github.com/codefreshdemo/cf-yml-example-build-dockerfile-inroot. Feel free to fork it if you want to follow along.
If you don’t already have a Codefresh account, you can easily create a free one from the sign-up page.
Building a Dockerfile from the root folder
By default docker uses the Dockerfile of the current folder if you run a single command like:
docker build . -t my-web-app
The same thing can also be achieved within a Codefresh pipeline:
codefresh.yml
version: '1.0'
steps:
main_clone:
title: Cloning main repository...
type: git-clone
repo: 'codefreshdemo/cf-yml-example-build-dockerfile-inroot'
revision: 'master'
git: github
build_my_app:
title: Building Node.Js Docker Image
type: build
image_name: my-app
working_directory: '${{main_clone}}'
tag: 'master'
dockerfile: Dockerfile
This pipeline checks out the source code of the repository and then builds a dockerfile found at the root folder of the project.
You could also change the Docker build context by editing the working_directory
property. By default it is looking at the root folder of the project, but any subfolder path is also valid.