@@ -11,20 +11,6 @@ import (
1111 "github.com/replicate/cog/pkg/model"
1212)
1313
14- const SectionPrefix = "### --> "
15-
16- const (
17- SectionStartingBuild = "Starting build"
18- SectionInstallingSystemPackages = "Installing system packages"
19- SectionInstallingPythonPrerequisites = "Installing Python prerequisites"
20- SectionInstallingPython = "Installing Python"
21- SectionInstallingPythonRequirements = "Installing Python requirements"
22- SectionInstallingPythonPackages = "Installing Python packages"
23- SectionInstallingCog = "Installing Cog"
24- SectionCopyingCode = "Copying code"
25- SectionPreInstall = "Running pre-install script"
26- )
27-
2814//go:embed embed/cog.whl
2915var cogWheelEmbed []byte
3016
@@ -138,7 +124,7 @@ func (g *DockerfileGenerator) aptInstalls() (string, error) {
138124 if len (packages ) == 0 {
139125 return "" , nil
140126 }
141- return g . sectionLabel ( SectionInstallingSystemPackages ) + "RUN apt-get update -qq && apt-get install -qy " +
127+ return "RUN apt-get update -qq && apt-get install -qy " +
142128 strings .Join (packages , " " ) +
143129 " && rm -rf /var/lib/apt/lists/*" , nil
144130}
@@ -148,7 +134,7 @@ func (g *DockerfileGenerator) installPython() (string, error) {
148134
149135 py := g .Config .Environment .PythonVersion
150136
151- return g . sectionLabel ( SectionInstallingPythonPrerequisites ) + `ENV PATH="/root/.pyenv/shims:/root/.pyenv/bin:$PATH"
137+ return `ENV PATH="/root/.pyenv/shims:/root/.pyenv/bin:$PATH"
152138RUN apt-get update -q && apt-get install -qy --no-install-recommends \
153139 make \
154140 build-essential \
@@ -170,7 +156,7 @@ RUN apt-get update -q && apt-get install -qy --no-install-recommends \
170156 git \
171157 ca-certificates \
172158 && rm -rf /var/lib/apt/lists/*
173- ` + g . sectionLabel ( SectionInstallingPython + " " + g . Config . Environment . PythonVersion ) + fmt .Sprintf (`RUN curl https://pyenv.run | bash && \
159+ ` + fmt .Sprintf (`RUN curl https://pyenv.run | bash && \
174160 git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest && \
175161 pyenv install-latest "%s" && \
176162 pyenv global $(pyenv install-latest --print "%s")` , py , py ), nil
@@ -187,8 +173,7 @@ func (g *DockerfileGenerator) installCog() (string, error) {
187173 return "" , fmt .Errorf ("Failed to write %s: %w" , cogFilename , err )
188174 }
189175 g .generatedPaths = append (g .generatedPaths , cogPath )
190- return g .sectionLabel (SectionInstallingCog ) +
191- fmt .Sprintf (`COPY .cog/tmp/%s /tmp/%s
176+ return fmt .Sprintf (`COPY .cog/tmp/%s /tmp/%s
192177RUN pip install /tmp/%s` , cogFilename , cogFilename , cogFilename ), nil
193178}
194179
@@ -197,7 +182,7 @@ func (g *DockerfileGenerator) pythonRequirements() (string, error) {
197182 if reqs == "" {
198183 return "" , nil
199184 }
200- return g . sectionLabel ( SectionInstallingPythonRequirements ) + fmt .Sprintf (`COPY %s /tmp/requirements.txt
185+ return fmt .Sprintf (`COPY %s /tmp/requirements.txt
201186RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt` , reqs ), nil
202187}
203188
@@ -222,11 +207,11 @@ func (g *DockerfileGenerator) pipInstalls() (string, error) {
222207 extraIndexURLs += "--extra-index-url=" + indexURL
223208 }
224209
225- return g . sectionLabel ( SectionInstallingPythonPackages ) + "RUN pip install " + findLinks + " " + extraIndexURLs + " " + strings .Join (packages , " " ), nil
210+ return "RUN pip install " + findLinks + " " + extraIndexURLs + " " + strings .Join (packages , " " ), nil
226211}
227212
228213func (g * DockerfileGenerator ) copyCode () string {
229- return g . sectionLabel ( SectionCopyingCode ) + `COPY . /src`
214+ return `COPY . /src`
230215}
231216
232217func (g * DockerfileGenerator ) command () string {
@@ -241,15 +226,11 @@ func (g *DockerfileGenerator) preInstall() string {
241226 lines := []string {}
242227 for _ , run := range g .Config .Environment .PreInstall {
243228 run = strings .TrimSpace (run )
244- lines = append (lines , g . sectionLabel ( SectionPreInstall + " " + run ) + "RUN " + run )
229+ lines = append (lines , "RUN " + run )
245230 }
246231 return strings .Join (lines , "\n " )
247232}
248233
249- func (g * DockerfileGenerator ) sectionLabel (label string ) string {
250- return fmt .Sprintf ("RUN %s%s\n " , SectionPrefix , label )
251- }
252-
253234func filterEmpty (list []string ) []string {
254235 filtered := []string {}
255236 for _ , s := range list {
0 commit comments