Zaks
Zaks

Reputation: 700

Dockerfile split

My python folder structure is as below

|_ _ helper
|_ _ Action1
|_ _ Action2


Action1 and Action2 use helper package .

I want to make dockerfile which is split as below

Docker file Base -> which contains common packages like pika which are necessary to build Action1 and Action2


Individual docker file images -> Individual docker file for Action1 and Action2 modules.

Since I cannot do cd .. inside Action1 and Action2 since docker context is sent to daemon whenever dockerfile is built.

Please suggest how to proceed on the above

Upvotes: 0

Views: 56

Answers (1)

ItayB
ItayB

Reputation: 11357

In docker build command you can specify which folder is your root folder (the context) - this is the last argument ../ in the example below.

Assuming your dockerfile inside Action1 folder and your present working directory Action1 you can run:

~/Action1# docker build -f dockerfile -t <image_name> ../

Note/Tip: you can add .dockerignore file in the parent directory to reduce the time that's take docker to load your context into memory (if parent directory is too big.

Good luck!

Upvotes: 1

Related Questions