Docker Community Forums

Share and learn in the Docker community.

How to manage image dependencies for local development?


(Heyhgl) #1

Hi,

I’m using docker as my local development environment, and it works really great.

But the pain comes when it comes to manage image dependencies.

For example, say I’m developing a go program. I create two images, one for production, which uses multi stage Dockerfile to build an alpine image containing the built go program. And another for development, which is based on the production image and, again, uses multi stage Dockerfile to add delve for debugging.

The set up is something like

# Dockerfile-prod
FROM: golang:alpine
ADD . /go/src/app
RUN go install app

FROM: alpine
COPY --from=0 /go/bin/app /usr/local/bin

and

# Dockerfile-dev
FROM: golang:alpine
RUN go get github.com/derekparker/delve/cmd/dlv

FROM: production
COPY --from=0 /go/bin/dlv /usr/local/bin

Now the question is, when I change my app’s source code, how do I automatically build both production and development images?

I know docker hub can do auto build, but pushing and pulling are too time consuming, not suited for rapid local development, and I heard that docker hub doesn’t cache layers, so it’s going to take a long time to do auto build.

Another approach I think is to use make, but I don’t know what should be the generated file that depends on the go source files. Should I touch empty file to designate that a particular image is built? Doesn’t sound very optimal.

I wonder if there is a better way? How do you manage image dependencies while doing local development?


(Heyhgl) #2

Any suggestions? Thanks in advance.