Skip to content

Conversation

@technillogue
Copy link
Contributor

@technillogue technillogue commented Jul 25, 2023

For building tiny images and modifying existing images with less pain

This is also intended as an escape hatch for when cog's dockerfile generation is inadequate. You can use cog debug as a starting point and edit that.

If this is merged, we can revert stuff like #1289. This provides for edge cases where you need a dependency to compile packages that you don't want at runtime, and various other problems.

This is also mentioned in https://github.com/replicate/cog/blob/main/pkg/config/config.go#L20

Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
@zeke
Copy link
Member

zeke commented Jul 26, 2023

Hi there. Thanks for sharing your work. 👍🏼

If you think this is something that could be generally useful for others, would you be willing to write some docs explaining the rationale behind these changes and what they make possible?

@technillogue
Copy link
Contributor Author

technillogue commented Jul 26, 2023

The main usecase for this is developing smaller images, such as https://github.com/replicate/cog-stable-diffusion/blob/syl/pget/Dockerfile

It also provides for doing this:

FROM r8.im/username/modelname@sha256:xyzxyzxyzxyz
COPY ./fixed_predict.py /src/predict.py

There are issues where you want to try small tweaks such as sprinkling in some .to("cuda") calls but would rather not redo the entire build process. Using FROM makes that easier.

To use this, all you need to do is add a Dockerfile in the working directory and not used --separate-weights.

Should I put this documentation somewhere else?

Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
@technillogue technillogue changed the title custom dockerfile for powerusers and hackers custom dockerfile Sep 11, 2023
@technillogue
Copy link
Contributor Author

@mattt, so we have a few options about configuring it

  1. leave it as-is: if there's a file named Dockerfile, use that, otherwise do nothing
  2. a section in cog.yaml under build
  3. yet another flag

For (3) we could do cmd.Flags().Lookup("dockerfile").NoOptDefVal = "Dockerfile" so that you could either pass --dockerfile <path> or just --dockerfile.

Other reference material includes flyctl's --dockerfile string Path to a Dockerfile. Defaults to the Dockerfile in the working directory, and their behavior of using dockerfiles if present but otherwise trying to guess a buildpak for a given app.

@technillogue technillogue requested a review from mattt September 11, 2023 23:24
@mattt
Copy link
Contributor

mattt commented Sep 12, 2023

@technillogue I think --dockerfile <path> is the best option. It also lets you point at multiple Dockerfiles, allowing for things like dev/prod variants, easier debugging between two versions, and monorepos with multiple models.

Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@mattt mattt force-pushed the syl/custom-dockerfile branch from 2b49211 to 7b8dcf4 Compare September 22, 2023 13:32
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@mattt mattt force-pushed the syl/custom-dockerfile branch from 7b8dcf4 to 83a9bdd Compare September 22, 2023 13:35
@mattt
Copy link
Contributor

mattt commented Sep 22, 2023

@technillogue Any idea why integration tests are failing with these changes?

Edit: Never mind, I figured it out. Pushing a fix soon.

@mattt mattt changed the title custom dockerfile Allow cog build and cog push to specify path to custom Dockerfile Sep 22, 2023
@mattt mattt enabled auto-merge (squash) September 22, 2023 18:17
@mattt mattt force-pushed the syl/custom-dockerfile branch from e3cecec to d870e9b Compare September 22, 2023 18:19
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@mattt mattt force-pushed the syl/custom-dockerfile branch from d870e9b to b30dabf Compare September 22, 2023 18:24
@mattt mattt merged commit 99d7ba5 into main Sep 22, 2023
@mattt mattt deleted the syl/custom-dockerfile branch September 22, 2023 18:36
@technillogue technillogue restored the syl/custom-dockerfile branch September 22, 2023 19:02
@technillogue technillogue deleted the syl/custom-dockerfile branch October 19, 2023 15:47
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.

4 participants