I have 3 Dockerfiles
./Dockerfile
FROM rust:1.43.1
WORKDIR /usr/src/hiro
COPY . .
RUN cargo build
./Dockerfile.master
FROM me/base
RUN chmod +x ./target/debug/hiro
CMD [ "./target/debug/hiro", "--master", "-p", "${PORT}" ]
./Dockerfile.worker
FROM me/base
RUN chmod +x ./target/debug/hiro
CMD [ "./target/debug/hiro", "--worker", "-p", "${PORT}" ]
Build (without Docker Compose)
docker build -t me/base -f Dockerfile .
and then,
docker build -t me/master -f Dockerfile.master .
docker build -t me/worker -f Dockerfile.worker .
I'm creating both master
and worker
, from the same base image that does the hard work of compiling source code. Somewhat like what explained in this Stackoverflow question: Docker Multi-Stage: How to split up into multiple Dockerfiles
Question
How can I configure my docker-compose.yml to build both images from the same base image?