2

Forgive me if this is an obvious question. I am fairly new to docker and I am having trouble understanding the installation instructions here: https://hub.docker.com/_/composer/

I want to use PHP Composer in my Limesurvey docker image that was generated with the following docker-compose "yml" file:

limesurvey-md:
  image: mariadb
  restart: always
  ports:
    - "32805:3306"
  environment:
    MYSQL_DATABASE: limesurvey
    MYSQL_ROOT_PASSWORD: password
    MYSQL_USER: limesurvey
    MYSQL_PASSWORD: password
  volumes:
    - limesurvey-db:/var/lib/mysql
    - limesurvey-dblog:/var/log/mysql
    - limesurvey-dbetc:/etc/mysql

limesurvey:
  image: fjudith/limesurvey
  restart: always
  ports:
    - "32705:80"
  volumes:
    - limesurvey-upload:/var/www/html/upload
  links:
    - limesurvey-md:mysql

What do I need to add to my yml file to accomplish this? If it helps, there is a directory called "application" in the Limesurvey image:

 /var/www/html/application

And how do I give this composer a command while it is in the container? I am using Windows 10 and the docker container is running the default linux environment. fjudith's Limesurvey container is using the last 2.X branch of Limesurvey (the one right before 3.X) and it is running PHP 7.2

2 Answers2

1

You can create a custom image with a dockerfile build, yo can specify the dockerfile name in the build section, the docker-compose.yml and dockerfile are in the same folder here i attach and example:

docker-compose.yml:

version: '3.1'
services:

  limesurvey-md:
    image: mariadb
    restart: always
    ports:
      - 32805:3306
    environment:
      MYSQL_DATABASE: limesurvey
      MYSQL_ROOT_PASSWORD: password
      MYSQL_USER: limesurvey
      MYSQL_PASSWORD: password
    volumes:
      - limesurvey-db:/var/lib/mysql
      - limesurvey-dblog:/var/log/mysql
      - limesurvey-dbetc:/etc/mysql

  limesurvey:
    build:
        context: .
        dockerfile: dockerfile
    restart: always
    ports:
      - 32705:80
    volumes:
      - limesurvey-upload:/var/www/html/upload
    links:
      - limesurvey-md:mysql

volumes:
    limesurvey-db:
        driver: local
    limesurvey-dblog:
        driver: local
    limesurvey-dbetc:
        driver: local
    limesurvey-upload:
        driver: local

dockerfile:

FROM "fjudith/limesurvey:latest"
LABEL maintainer="ing.brayan.cm@gmail.com"

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Brayan Caldera
  • 2,001
  • 2
  • 11
  • 20
0

Thanks Brayan! I just (10 minutes ago) figured out another way, you can also do a bash command. Since I was in Windows the two lines I had to do in my command prompt were

docker exec -it <my_container_name> bash

Then it put me into "/var/www/html#" where I did the following command:

$sudo curl -o /tmp/composer-setup.php https://getcomposer.org/installer && curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --snapshot && rm -f /tmp/composer-setup.*

I adapted the second line from here: Get composer (php dependency manager) to run on a docker image build

From there it's easy! You can just do

composer

and it guides you through the possible commands. It suggests not using the "root" administrator. I'll have to look into creating another user in the docker image.