Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Compose build context from git repository with Dockerfile inside folder

I would like to build a new image in my docker compose project using a git repository as I need to change some ARG vars.

My concern is that the Dockerfile is inside a folder of the git repository.

How can be specified a folder as build context using a git repository?

Repository: https://github.com/wodby/drupal-php/blob/master/7/Dockerfile

version: "2"
services:
  php:
    build:
      context: https://github.com/wodby/drupal-php.git
      dockerfile: 7/Dockerfile
      args:
         - BASE_IMAGE_TAG=7.1
         - WODBY_USER_ID=117
         - WODBY_GROUP_ID=111
      volumes:
          - ./:/var/www/html

I've tried the dockerfile property: "FOLDER/" + Dockerfile

But the repository uses relative paths, and it doesn't find dependencies:

 ---> 6cc2006e9102
Step 7/9 : COPY templates /etc/gotpl/
ERROR: Service 'phpe' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder740707850/templates: no such file or directory
like image 302
jorgetutor Avatar asked Jun 11 '26 23:06

jorgetutor


1 Answers

It should be this way: myrepo.git#:myfolder

version: "2"
services:
  php:
    build:
      context: https://github.com/wodby/drupal-php.git#:7
      args:
         - BASE_IMAGE_TAG=7.1
         - WODBY_USER_ID=117
         - WODBY_GROUP_ID=111
      volumes:
          - ./:/var/www/html

https://docs.docker.com/engine/reference/commandline/build/#git-repositories

like image 136
jorgetutor Avatar answered Jun 14 '26 00:06

jorgetutor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!