New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image and build together #2458

Merged
merged 2 commits into from Jan 12, 2016

Conversation

Projects
None yet
4 participants
@dnephin
Contributor

dnephin commented Nov 25, 2015

Fixes #2092

Allow both image and build in a service config, and use image as the image name when building, if it exists.

@dnephin dnephin added this to the 1.6.0 milestone Nov 25, 2015

@vdemeester vdemeester referenced this pull request Dec 29, 2015

Closed

Libcompose 1.0.0 <-> Compose 1.6.0 features #124

105 of 147 tasks complete
@dnephin

This comment has been minimized.

Show comment
Hide comment
@dnephin

dnephin Jan 12, 2016

Contributor

Rebased, now only applies to V2 config.

Contributor

dnephin commented Jan 12, 2016

Rebased, now only applies to V2 config.

dnephin added some commits Jan 12, 2016

Fix pep8 errors from the new pep8 release.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Allow both image and build together.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
@aanand

This comment has been minimized.

Show comment
Hide comment
@aanand

aanand Jan 12, 2016

Contributor

LGTM

Contributor

aanand commented Jan 12, 2016

LGTM

aanand added a commit that referenced this pull request Jan 12, 2016

@aanand aanand merged commit 0c626e6 into docker:master Jan 12, 2016

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
docker/dco-signed All commits signed
Details
documentation success 1 tests run, 1 skipped, 0 failed.
Details
janky Jenkins build Compose-PRs 2016 has succeeded
Details

@dnephin dnephin deleted the dnephin:image_and_build_together branch Jan 12, 2016

@graingert

This comment has been minimized.

Show comment
Hide comment
@graingert

graingert Jan 28, 2016

Contributor

@dnephin does this allow something like:

# docker-compose.yml
production:
   - image: ham/spam
   - build: ./spam
development:
   - image: ham/spam-dev
   - build: ./spam
   - dockerfile: Dockerfile-dev
# spam/Dockerfile
FROM ubuntu
RUN apt-get install nginx npm
COPY . /usr/bin/src/
RUN npm build
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
# spam/Dockerfile-dev
FROM ham/spam # build on parent ham/spam.
RUN npm start # start live reloader
Contributor

graingert commented Jan 28, 2016

@dnephin does this allow something like:

# docker-compose.yml
production:
   - image: ham/spam
   - build: ./spam
development:
   - image: ham/spam-dev
   - build: ./spam
   - dockerfile: Dockerfile-dev
# spam/Dockerfile
FROM ubuntu
RUN apt-get install nginx npm
COPY . /usr/bin/src/
RUN npm build
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
# spam/Dockerfile-dev
FROM ham/spam # build on parent ham/spam.
RUN npm start # start live reloader
@aanand

This comment has been minimized.

Show comment
Hide comment
@aanand

aanand Jan 28, 2016

Contributor

@graingert Yes, but you have to use the v2 file format to use image and build together:

version: 2
services:
  production:
    image: ham/spam
    build: ./spam
  development:
    image: ham/spam-dev
    build:
      context: ./spam
      dockerfile: Dockerfile-dev

You probably wouldn't actually define development and production as separate services in the same file, though. More likely you'd put the core config in docker-compose.yml and the development override in docker-compose.override.yml:

# docker-compose.yml
version: 2
services:
  spam:
     image: ham/spam
     build: ./spam

# docker-compose.override.yml
version: 2
services:
  spam:
    image: ham/spam-dev
    build:
      context: ./spam
      dockerfile: Dockerfile-dev
Contributor

aanand commented Jan 28, 2016

@graingert Yes, but you have to use the v2 file format to use image and build together:

version: 2
services:
  production:
    image: ham/spam
    build: ./spam
  development:
    image: ham/spam-dev
    build:
      context: ./spam
      dockerfile: Dockerfile-dev

You probably wouldn't actually define development and production as separate services in the same file, though. More likely you'd put the core config in docker-compose.yml and the development override in docker-compose.override.yml:

# docker-compose.yml
version: 2
services:
  spam:
     image: ham/spam
     build: ./spam

# docker-compose.override.yml
version: 2
services:
  spam:
    image: ham/spam-dev
    build:
      context: ./spam
      dockerfile: Dockerfile-dev
@graingert

This comment has been minimized.

Show comment
Hide comment
@graingert

graingert Jan 28, 2016

Contributor

@aanand How does docker-compose know it needs to build "ham/spam" for docker-compose.override.yml's Dockerfile-dev to work?

Contributor

graingert commented Jan 28, 2016

@aanand How does docker-compose know it needs to build "ham/spam" for docker-compose.override.yml's Dockerfile-dev to work?

@aanand

This comment has been minimized.

Show comment
Hide comment
@aanand

aanand Jan 28, 2016

Contributor

I see what you were getting at now. Compose doesn't support dependent builds - you should use a tool like Shipwright for that.

Contributor

aanand commented Jan 28, 2016

I see what you were getting at now. Compose doesn't support dependent builds - you should use a tool like Shipwright for that.

@graingert

This comment has been minimized.

Show comment
Hide comment
@graingert

graingert Jan 28, 2016

Contributor

@aanand ah nice, thanks

Contributor

graingert commented Jan 28, 2016

@aanand ah nice, thanks

@dnephin

This comment has been minimized.

Show comment
Hide comment
@dnephin

dnephin Jan 28, 2016

Contributor

I've been prototyping a tool in https://github.com/dnephin/dobi that would support building chains of images (as well as a bunch of other things). There are a few docs and examples, but it could definitely use more, I need one for the ordered build use case.

Contributor

dnephin commented Jan 28, 2016

I've been prototyping a tool in https://github.com/dnephin/dobi that would support building chains of images (as well as a bunch of other things). There are a few docs and examples, but it could definitely use more, I need one for the ordered build use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment