-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Is it possible to have build-only service? #4744
Comments
See my answer to a similar question in #4489 |
@shin- thank you but it's more like "we don't support it/was not designed to do that etc". running 2 commands - this is obvious, but not nice. Have you tried any other tools like dobi? |
I have used dobi. It's a great tool, written by @dnephin who has been a Compose maintainer for a while, so I highly recommend trying it out. |
With services:
test-build-only:
build:
dockerfile_inline: |
FROM scratch
# choose one flavor between two entrypoints below
entrypoint: sh -c exit
entrypoint: 'true'
some-service-build-on-test:
build:
args:
COMPOSE_PROJECT_NAME: $COMPOSE_PROJECT_NAME and in the Dockerfile of service FROM ${COMPOSE_PROJECT_NAME}-test-build-only the image of services That two flavor of entrypoints only differences in running a shell Make sure to build the image of service docker compose build test-build-only && docker compose build as currently there's no way to set the building order of uncached images in Note if you are not using services:
some-service-build-on-test:
build:
args:
COMPOSE_PROJECT_NAME: $COMPOSE_PROJECT_NAME ARG COMPOSE_PROJECT_NAME
FROM ${COMPOSE_PROJECT_NAME}-test-build-only For your case in 8 years ago: services:
src:
build:
context: deploy/src
image: myname/base
+ entrypoint: sh -c exit
+ entrypoint: 'true'
fpm:
build:
context: deploy/fpm
args:
COMPOSE_PROJECT_NAME: $COMPOSE_PROJECT_NAME
image: myname/fpm and replace the ARG COMPOSE_PROJECT_NAME
FROM ${COMPOSE_PROJECT_NAME}-src finally: docker compose build src && docker compose build |
And if you are using build-only service to achieve extending Dockerfile, also try |
and
can be simplified with some-service-build-on-test:
build:
dockerfile_inline:
# syntax=docker/dockerfile:1
FROM ${COMPOSE_PROJECT_NAME}-test-build-only
depends_on:
- test-build-only And with some-service-build-on-test:
image: ${COMPOSE_PROJECT_NAME}-test-build-only the |
Suppose I have the following config (simplified):
Dockerfile for fpm is located in deploy/fpm, Dockerfile for src is located in deploy/src
Dockerfile for myname/fpm image extends from myname/base image
Therefore I need to include both services (src & fpm), and make containers from them.
Is it possible to specify that src service is for build only.
So it first builds myname/base image and then myname/fpm image.
If I omit src it will not be able to find myname/base image since it was not build yet.
The text was updated successfully, but these errors were encountered: