Skip to content

Split Dockerfile in two stages: builder and runtime.#2347

Merged
ahojnnes merged 1 commit intocolmap:mainfrom
pablospe:patch-1
Jan 12, 2024
Merged

Split Dockerfile in two stages: builder and runtime.#2347
ahojnnes merged 1 commit intocolmap:mainfrom
pablospe:patch-1

Conversation

@pablospe
Copy link
Copy Markdown
Contributor

Splitting the Dockerfile in two stages reduces the size of the final image considerably, since all the build dependencies are not needed.

You can still create the tag for the stages separately:

docker build --target builder -t colmap:builder .
docker build --target runtime -t colmap:runtime .

But the default command (without --target) is the last stage, so:

docker build -t colmap:latest .

will refer to --target runtime because it is the last stage in the Dockerfile.

@ahojnnes
Copy link
Copy Markdown
Contributor

Thanks, great improvement.

@ahojnnes ahojnnes merged commit fb3fa6a into colmap:main Jan 12, 2024
Comment thread docker/Dockerfile
Comment thread docker/Dockerfile
@pablospe
Copy link
Copy Markdown
Contributor Author

FYI, this PR reduces the docker image ~3GB :)

image

(image from https://hub.docker.com/r/colmap/colmap)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants