1

For a php application I have the following docker-compose.yml:

version:'2'
services:
  service:
    build:
      context: .
      dockerfile: Dockerfile
    image: "service"

  service_debug:
    build:
      context: .
      dockerfile: Dockerfile_debug
    image: "service_debug"
    ports:
      - "9001:9001"

Also in my Dockerfile I have the following context

FROM php:7.0-fpm-alpine
MAINTAINER Monkey D. Luffy

EXPOSE 9000

VOLUME /var/www/html

#Do build stuff
#....

I also have an another dockerfile where I base it on the docker image I build with the dockerfile above where I install the xdebug. This file is named (according to docker-compose.yml) Dockerfile_debug. This image will contain some debuging tools (eg in my case xdebug but it can be any tool or setting):

FROM service
MAINTAINER Kurosaki Ichigo

EXPOSE 9001
EXPOSE 9000

RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
RUN sed -i '1 a xdebug.remote_autostart=true' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN sed -i '1 a xdebug.remote_mode=req' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN sed -i '1 a xdebug.remote_handler=dbgp' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN sed -i '1 a xdebug.remote_connect_back=1 ' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN sed -i '1 a xdebug.remote_port=9001' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN sed -i '1 a xdebug.remote_host=127.0.0.1' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN sed -i '1 a xdebug.remote_enable=1' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

So my question is when I run docker-compose build how to set the build sequence between 2 services and how to make the image I build from service_debug to get based on the latest image from service.

In otherwords I want to produce the production ready image and a debug image at the same time in order to be able to test if my application will work in my production-ready docker image.

1 Answer 1

2

Have you tried with docker links? https://docs.docker.com/compose/compose-file/#links

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.