1

I have the following Dockerfile

FROM myabse

ARG SERVER_CONTEXT_PATH=com-ifx

COPY ./hue-com-ifx-front/target-server-side/com-ifx.war /opt/tomcat/webapps/${SERVER_CONTEXT_PATH}.war

CMD ["/opt/tomcat/bin/catalina.sh", "run"]

When I try build the docker image like this

sudo docker build --build-arg SERVER_CONTEXT_PATH=mywar -t com-ifx:latest and run the image using sudo docker run -p 8080:8080 com-ifx:latest

The war file copied is mywar.war

I tried to do the same in .drone.yml

docker:
    image: plugins/docker
    registry: registry.paas.workslan
    repo: registry.paas.workslan/ifx-prestaging/com-ifx
    build_args: 
      - SERVER_CONTEXT_PATH=mywar
    secrets: [ docker_username, docker_password ]
    tags: latest
    when:
      branch: ticket-*
  docker_publish_feature_branch:
    image: plugins/docker
    registry: registry.paas.workslan
    repo: registry.paas.workslan/ifx-prestaging/com-ifx
    secrets: [ docker_username, docker_password ]
    tags: ${DRONE_COMMIT_BRANCH}
    when:
      branch: [ticket-*]

But the name of the war is always com-ifx.war. I want it to be mywar.war. How should I do in this in .drone.yml

kosta
  • 4,302
  • 10
  • 50
  • 104

1 Answers1

1

In my case I used two changes from your script. Which are:

In Dokerfile I used, the format $VARIABLE or "$VARIABLE" to reference the variable.

And in .drone.yml file the variable is specified as

build_args_from_env: [ VARIABLE ]

This works for me

Bessy George
  • 109
  • 1
  • 4
  • The thread looks old, but might be helpful for someone who bumps into this issue: http://plugins.drone.io/drone-plugins/drone-docker/ – user1234 Mar 22 '21 at 16:53