Build an Image - Specify Dockerfile Location

Using this repository we’ll help you get up to speed with basic functionality such as: building Docker images.

This project uses Node JS to build an application which will eventually become a distributable Docker image.

If your Dockerfile is not maintained in the root directory of your repository, you can specify its location relative to the root directory using the dockerfile attribute.

codefresh.yml

version: '1.0'
steps:
  build_the_image:
    type: build
    description: Builds my service
    dockerfile: dockerfiles/Dockerfile.prod
    image_name: myuser/myservice
    tag: develop # ${{CF_BRANCH}}

For more information about the steps for the build-the-image command, click HERE.

If you need to specify path to build context, you can do it through working_directory like in example below.\nBuild context is where we can find your Dockerfile as well as running commands. Your Dockerfile must be relative to this directory.

codefresh.yml

version: '1.0'
steps:
  build_the_image:
    type: build
    description: Builds my service
    dockerfile: Dockerfile
    working_directory: ${{main_clone}}/path_build_context
    image_name: myuser/myservice
    tag: develop # ${{CF_BRANCH}}
Example

Just head over to the example repository in Github and follow the instructions there.