Drone docker plugin (plugins/docker, plugins/ecr) to set context

During docker image build we have a requirement to change directory. I know there is a solution to set the path of the Dockerfile, but being in the Operation team we are not allowed to make any change in Dockerfile to adjust the relative path in the docker file. While using the docker plugin, is there any way we can change the path to set the context for docker build.

1 Like

the docker plugin has a context attribute

kind: pipeline
name: default

steps:
- name: docker  
  image: plugins/docker
  settings:
    username: kevinbacon
    password: pa55word
    repo: foo/bar
    tags: latest
    context: path/in/repo

Thanks so much for quick reply. I am gonna try this out.

@bradrydzewski Thanks it worked for me.

This does not work for me.

I figured it out: https://stackoverflow.com/questions/64233848/unable-to-set-context-in-drone-plugin-drone-gcr-and-drone-docker

@Emilio_Hemken Below works for us. Drone version 1.6.0


kind: pipeline
name: app

steps:
- name: bake  
  image: plugins/docker
  settings:
    registry: <docker_registry_uri>
    username:
      from_secret: docker_username
    password:
      from_secret: docker_password
    dockerfile: docker/Dockerfile
    target: prod
    repo: <docker_repo_uri>
    tags:
      - latest
      - '1.1.1'

You can set context as well, in some cases we do as well.


kind: pipeline
name: app

steps:
- name: bake  
  image: plugins/docker
  settings:
    registry: <docker_registry_uri>
    context: ./some_path/
    username:
      from_secret: docker_username
    password:
      from_secret: docker_password
    dockerfile: docker/Dockerfile
    target: prod
    repo: <docker_repo_uri>
    tags:
      - latest
      - '1.1.1'