urbantrout / craftcms

Craft CMS Docker Image
MIT License
76 stars 32 forks source link

Question about composer.json #4

Closed matthewcummings closed 5 years ago

matthewcummings commented 6 years ago

First of all, thank you for creating this image, it's super handy!

Secondly, I have a question about composer.json, I'd like to use my own composer.json file. I've looked at dependencies.sh and I think the best approach for me would be to just create my own Dockerfile based on your image.

There are some things I need (VCS repo definitions for example) which I think will only work if I run composer against my own file.

urbantrout commented 6 years ago

Thank you!

You can add dependencies from other git repos as shown in the README:

https://github.com/urbantrout/craftcms#plugins

If you need further modifications on your compser.json you could add this file as a volume in your docker-compose.yml. maybe that helps.

    volumes:
      - ./composer.json:/var/www/html/composer.json
matthewcummings commented 6 years ago

@urbantrout Yes, the dependency handling is cool, but I have some additional config in my composer.json file. However, I didn't see any place in your existing code where composer install is being executed.

For example, if I add the volumes line you mentioned, what will actually consume it? My idea was to create a new Dockerfile based off of yours which do exactly that.

urbantrout commented 6 years ago

Maybe I should add the possibility to execute shell scripts after start. Similar to the db dump but instead of import the file to a DB they just get executed.

maxhoffmann commented 6 years ago

Hey 👋

I’m also trying to add additional changes to composer.json. Also I’m not quite sure how to add dependencies with versions:

From the README:

    volumes:
      - ./path/to/plugin:/plugins/plugin # If you want a local plugin for composer

    environment:
      DEPENDENCIES: >- # additional composer packages (must be comma separated)
        craftcms/redactor,
        [vendor/package-name:branch-name]https://url-to-the-git-repo.git # Branch name should be prefixed with dev-${branchname}
        [vendor/package-name:version]/path/to/volume # Version as 1.0.0

Does this mean this is how I’d add a package with a version?

    volumes:
      - ./path/to/plugin:/plugins/plugin # If you want a local plugin for composer

    environment:
      DEPENDENCIES: >- # additional composer packages (must be comma separated)
        craftcms/cms:3.0.11,
        craftcms/redactor:2.0.1
urbantrout commented 6 years ago

@maxhoffmann yes, you can install a specific version of a composer package with the syntax vendor/package-name:version. But this does not seem to work with craftcms/cms. This is due to the fact that the image comes preinstalled with Craft CMS. You can upgrade the CMS in the Control Panel but not downgrade it.

urbantrout commented 5 years ago

The docker image now updates all the composer dependencies on startup. This includes Craft CMS itself.

urbantrout commented 5 years ago

@matthewcummings If you add a volume for a plugin you can install this plugin via the docker-compose.yaml by adding this line to the DEPENDENCIES array:

[vendor/package-name:version]/path/to/volume # Version as 1.0.0