Skip to content

Use a standard filesystem structure in all docker images#5625

Closed
deivid-rodriguez wants to merge 4 commits intomainfrom
deivid-rodriguez/standard-filesystem-layout
Closed

Use a standard filesystem structure in all docker images#5625
deivid-rodriguez wants to merge 4 commits intomainfrom
deivid-rodriguez/standard-filesystem-layout

Conversation

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

And make it the same as in our repository.

While working on improving #5617, I wanted to change the way we install native helpers to be like this:

diff --git a/Dockerfile b/Dockerfile
index 566941768..0b858d95d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -267,32 +267,32 @@ USER dependabot
 
 ENV DEPENDABOT_NATIVE_HELPERS_PATH="/opt"
 
-COPY --chown=dependabot:dependabot composer/helpers /opt/composer/helpers
-RUN bash /opt/composer/helpers/v1/build \
-  && bash /opt/composer/helpers/v2/build
+COPY --chown=dependabot:dependabot composer/helpers /home/dependabot/dependabot-core/composer/helpers
+RUN bash /home/dependabot/dependabot-core/composer/helpers/v1/build \
+  && bash /home/dependabot/dependabot-core/composer/helpers/v2/build
 
-COPY --chown=dependabot:dependabot bundler/helpers /opt/bundler/helpers
-RUN bash /opt/bundler/helpers/v1/build \
-  && bash /opt/bundler/helpers/v2/build
+COPY --chown=dependabot:dependabot bundler/helpers /home/dependabot/dependabot-core/bundler/helpers
+RUN bash /home/dependabot/dependabot-core/bundler/helpers/v1/build \
+  && bash /home/dependabot/dependabot-core/bundler/helpers/v2/build
 
-COPY --chown=dependabot:dependabot go_modules/helpers /opt/go_modules/helpers
-RUN bash /opt/go_modules/helpers/build
+COPY --chown=dependabot:dependabot go_modules/helpers /home/dependabot/dependabot-core/go_modules/helpers
+RUN bash /home/dependabot/dependabot-core/go_modules/helpers/build
 
-COPY --chown=dependabot:dependabot hex/helpers /opt/hex/helpers
-ENV MIX_HOME="/opt/hex/mix"
-RUN bash /opt/hex/helpers/build
+COPY --chown=dependabot:dependabot hex/helpers /home/dependabot/dependabot-core/hex/helpers
+ENV MIX_HOME="/home/dependabot/dependabot-core/hex/mix"
+RUN bash /home/dependabot/dependabot-core/hex/helpers/build
 
-COPY --chown=dependabot:dependabot pub/helpers /opt/pub/helpers
-RUN bash /opt/pub/helpers/build
+COPY --chown=dependabot:dependabot pub/helpers /home/dependabot/dependabot-core/pub/helpers
+RUN bash /home/dependabot/dependabot-core/pub/helpers/build
 
-COPY --chown=dependabot:dependabot npm_and_yarn/helpers /opt/npm_and_yarn/helpers
-RUN bash /opt/npm_and_yarn/helpers/build
+COPY --chown=dependabot:dependabot npm_and_yarn/helpers /home/dependabot/dependabot-core/npm_and_yarn/helpers
+RUN bash /home/dependabot/dependabot-core/npm_and_yarn/helpers/build
 
-COPY --chown=dependabot:dependabot python/helpers /opt/python/helpers
-RUN bash /opt/python/helpers/build
+COPY --chown=dependabot:dependabot python/helpers /home/dependabot/dependabot-core/python/helpers
+RUN bash /home/dependabot/dependabot-core/python/helpers/build
 
-COPY --chown=dependabot:dependabot terraform/helpers /opt/terraform/helpers
-RUN bash /opt/terraform/helpers/build
+COPY --chown=dependabot:dependabot terraform/helpers /home/dependabot/dependabot-core/terraform/helpers
+RUN bash /home/dependabot/dependabot-core/terraform/helpers/build
 
 ENV PATH="$PATH:/opt/terraform/bin:/opt/python/bin:/opt/go_modules/bin"
 

So that no duplicated file trees at /opt/<ecosystem> and /opt/<ecosystem>/helpers are generated.

However, I believe this will generate similar confusing duplication at /home/dependabot/dependabot-core/<ecosystem>/helpers, and /home/dependabot/<ecosystem>/helpers in the updater image.

I want to experiment with unifying the layout across all images & the source repository.

@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/standard-filesystem-layout branch 4 times, most recently from f47ebb2 to e31c7fa Compare September 5, 2022 11:14
@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

I think the current failures happen because dependabot/cli hardcodes some environment variables?

Maybe a patch like this would fix things

diff --git a/internal/infra/updater.go b/internal/infra/updater.go
index 90ba236..103d603 100644
--- a/internal/infra/updater.go
+++ b/internal/infra/updater.go
@@ -153,6 +153,21 @@ func (u *Updater) InstallCertificates(ctx context.Context) error {
 }
 
 func userEnv(proxyHost string, apiPort int) []string {
+       inputDir := os.Getenv("DEPENDABOT_JOB_PATH")
+       if inputDir == "" {
+               inputDir = guestInputDir
+       }
+
+       outputDir := os.Getenv("DEPENDABOT_OUTPUT_PATH")
+       if outputDir == "" {
+               outputDir = guestOutputDir
+       }
+
+       repoDir := os.Getenv("DEPENDABOT_REPO_CONTENTS_PATH")
+       if repoDir == "" {
+               repoDir = guestRepoDir
+       }
+
        return []string{
                fmt.Sprintf("http_proxy=http://%s:1080", proxyHost),
                fmt.Sprintf("HTTP_PROXY=http://%s:1080", proxyHost),
@@ -160,9 +175,9 @@ func userEnv(proxyHost string, apiPort int) []string {
                fmt.Sprintf("HTTPS_PROXY=http://%s:1080", proxyHost),
                fmt.Sprintf("DEPENDABOT_JOB_ID=%v", jobID),
                fmt.Sprintf("DEPENDABOT_JOB_TOKEN=%v", ""),
-               fmt.Sprintf("DEPENDABOT_JOB_PATH=%v", guestInputDir),
-               fmt.Sprintf("DEPENDABOT_OUTPUT_PATH=%v", filepath.Join(guestOutputDir, fetcherOutputFile)),
-               fmt.Sprintf("DEPENDABOT_REPO_CONTENTS_PATH=%v", guestRepoDir),
+               fmt.Sprintf("DEPENDABOT_JOB_PATH=%v", inputDir),
+               fmt.Sprintf("DEPENDABOT_OUTPUT_PATH=%v", filepath.Join(outputDir, fetcherOutputFile)),
+               fmt.Sprintf("DEPENDABOT_REPO_CONTENTS_PATH=%v", repoDir),
                fmt.Sprintf("DEPENDABOT_API_URL=http://host.docker.internal:%v", apiPort),
                fmt.Sprintf("SSL_CERT_FILE=%v/ca-certificates.crt", certsPath),
                "UPDATER_ONE_CONTAINER=true",

I'll wait for some input here in any case!

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

By the way, this PR would also make #5609 unnecessary.

@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/standard-filesystem-layout branch 5 times, most recently from 140ceb4 to 74292a7 Compare December 7, 2022 15:26
@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/standard-filesystem-layout branch from 74292a7 to cbdf68e Compare January 12, 2023 18:36
@deivid-rodriguez deivid-rodriguez mentioned this pull request Jan 12, 2023
If the previous copies are correct, the ones after should be correct
too.
Which also matches our repository structure.
@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/standard-filesystem-layout branch from cbdf68e to 5825c0f Compare January 12, 2023 21:25
@jeffwidman
Copy link
Copy Markdown
Member

Stumbled across this... what's the plan here now that the docker images are split apart? I didn't review the code, as I figure you know off top of your head if this is still useful or not?

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

I'm honestly not sure if still relevant, but I will check and close this if it's not!

@deivid-rodriguez
Copy link
Copy Markdown
Contributor Author

I don't think this is worth even revisiting, and I never got it working anyways. Closing.

@deivid-rodriguez deivid-rodriguez deleted the deivid-rodriguez/standard-filesystem-layout branch August 11, 2023 19:01
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