Last active
June 10, 2023 06:02
-
-
Save pebo/ae810238eb2a4e0d27334e0a0f9e5d3d to your computer and use it in GitHub Desktop.
docker compose with base image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage | |
docker compose up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
base: | |
image: base-image | |
build: | |
context: . | |
dockerfile: ./Dockerfile | |
target: base | |
deploy: | |
replicas: 0 | |
sub-with-build: | |
build: | |
context: . | |
dockerfile: ./Dockerfile | |
target: sub | |
command: echo 'sub-with-build' && cat /bar.txt | |
depends_on: | |
- base | |
sub-with-image: | |
image: base-image | |
command: echo 'sub-with-image' && cat /bar.txt | |
depends_on: | |
- base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine as base | |
RUN echo 'foo' > /foo.txt | |
RUN echo 'sleeping for 10s' && sleep 10 | |
FROM base-image as sub | |
RUN echo 'bar' > /bar.txt && cat /foo.txt >> /bar.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment