wodby / drupal-php

PHP docker container image for Drupal
https://wodby.com/stacks/drupal
MIT License
60 stars 80 forks source link

Jenkins Integration Build Args Help #56

Closed jorgetutor closed 6 years ago

jorgetutor commented 6 years ago

Hi,

I would like to run drupal4docker inside Jenkins.

In my machine, Jenkins has the properties:

I have a permissions issue as the files being mounted into the docker image uses Jenkins user owner/group.

I've seen that the PHP base image are there two arguments that can be overridden:

So I've changed my composer-override to:

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

But when I run docker-composer up -d I get

Removing intermediate container def219daa385
 ---> 679e10eddc94
Step 6/9 : USER wodby
 ---> Running in 24228b508cbf
Removing intermediate container 24228b508cbf
 ---> 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

What am I doing wrong? Any other way to run this docker image using Jenkins user with files permission compatibility?

Thanks!

csandanov commented 6 years ago

Those are the build arguments, not environment variables for customization, you'll have to rebuild the image with these arguments.

jorgetutor commented 6 years ago

This what I think I'm doing with the args property in the composer file, but it throws an exception. I'll open a new issue to cover that.

csandanov commented 6 years ago

Ohh... I'm sorry, I missed that you're using build. It seems the problem is that you're using an incorrect context, it should be a directory 7/ inside of the git repository, otherwise it can't find templates/ in your current context which is a git repo root.

jorgetutor commented 6 years ago

How can I specify this using a git repository as context? I've set the Dockerfile like 7/Dockerfile but it doesn't work.

Which alternatives/workaround can I use? Thanks!

jorgetutor commented 6 years ago

Found!

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

Thanks!

jorgetutor commented 6 years ago

One question, just to confirm. Is it possible to use the WODBY_USER_ID & GROUP with this image? If I want to change them Shall I need to use the original one (php)?

_One or more build-args [WODBY_USER_ID WODBY_GROUPID] were not consumed

csandanov commented 6 years ago

Yes, WODBY_USER_ID and WODBY_GROUP_ID are build args

jorgetutor commented 6 years ago

I see those args in the PHP docker image, not in the Drupal-PHP one. Does the Drupal-PHP image stores and uses those args over the PHP image? Sorry, I'm still new to Docker.

csandanov commented 6 years ago

wodby/drupal-php images based on wodby/php as indicated in README.

jorgetutor commented 6 years ago

This is why I think that the [WODBY_USER_ID WODBY_GROUP_ID] parameters are not available in the Drupal-PHP image, just in the main one (PHP). So if I want to change them I can't use the Drupal-PHP image Am I right?

csandanov commented 6 years ago

If you want to change user and group ids in drupal-php image, you should build your own wodby/php image with the provided build args and then build your own drupal-php image based on your php.