Skip to content

Re-organize Dockerfile#92

Merged
victorlin merged 6 commits intomasterfrom
victorlin/organize-dockerfile
Oct 14, 2022
Merged

Re-organize Dockerfile#92
victorlin merged 6 commits intomasterfrom
victorlin/organize-dockerfile

Conversation

@victorlin
Copy link
Copy Markdown
Member

@victorlin victorlin commented Oct 11, 2022

Description of proposed changes

Some improvements to the Dockerfile.

Related issue(s)

Testing

  • Checks pass
  • Manually check nextstrain/base:branch-victorlin-organize-dockerfile:
docker run nextstrain/base:build-20221013T234036Z ls -lR --time-style='+' /usr/local/{bin,libexec,share} > old.txt
docker run nextstrain/base:branch-victorlin-organize-dockerfile ls -lR --time-style='+' /usr/local/{bin,libexec,share} > new.txt
diff old.txt new.txt
# no diff!

@victorlin victorlin requested a review from a team October 11, 2022 23:49
@victorlin victorlin self-assigned this Oct 11, 2022
@victorlin victorlin force-pushed the victorlin/organize-dockerfile branch from 73048a5 to 472f556 Compare October 13, 2022 17:39
Copy link
Copy Markdown
Contributor

@tsibley tsibley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, love to see this get some attention. Really like 2ab774c in particular. A few notes below, nothing major.

Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile
@tsibley
Copy link
Copy Markdown
Contributor

tsibley commented Oct 13, 2022

I extended the diff a bit to check the rest of the dirs.

docker run nextstrain/base:build-20221005T235113Z ls -lR /usr/local/{bin,libexec,share} > old.txt
docker run nextstrain/base:branch-victorlin-organize-dockerfile ls -lR /usr/local/{bin,libexec,share} > new.txt

Looks fine.

pip works, but use pip3 for consistency.
@victorlin victorlin force-pushed the victorlin/organize-dockerfile branch from 472f556 to fecdb79 Compare October 13, 2022 23:49
`X` only sets all execute bits if there is at least one already set.
This isn't the case for some downloads, which is why it was set
individually. Instead of setting individually, just use `x` to set all
regardless of previous state.
These binaries are currently placed in the middle of pip installs. While
they are relevant to the Pangolin packages, this deviates from existing
organization of the Dockerfile which follows:

1. [builder] source builds
2. [builder] package manager installs
3. [final] direct downloads

Add notes that these are for ncov/Pangolin. Also download them in a way
that is consistent with other direct downloads.

Since these commands are no longer bound by the CACHE_DATE declaration
in the builder stage, they can take advantage of caching.
It's better to organize the Dockerfile for optimal version-pinning
caching and keep direct downloads separate from package manager
installs. This means it doesn't make sense to put the workflow-specific
dependencies at the bottom. Instead, we can add searchable comments to
each dependency to understand why it is included.
@victorlin victorlin force-pushed the victorlin/organize-dockerfile branch from fecdb79 to efcafe6 Compare October 13, 2022 23:55
Use these sections to organize the order of adding software tools:

1. Built from source
2. Pre-built binaries
3. Installed via pip
4. Nextstrain components and unpinned software

This means all software is managed in the builder stage. Use new
directories /out/* to copy from builder stage to final stage. This also
reduces the tight coupling of COPY --from=builder commands.

Also, use `&&` to chain related commands together in the same RUN to
reduce the number of layers.
@victorlin victorlin force-pushed the victorlin/organize-dockerfile branch from 8c3c27c to a7159ec Compare October 14, 2022 00:06
@victorlin
Copy link
Copy Markdown
Member Author

Will merge once CI and the manual diff check passes.

@victorlin
Copy link
Copy Markdown
Member Author

Updated diff check to ignore timestamps and use newer image:

docker run nextstrain/base:build-20221013T234036Z ls -lR --time-style='+' /usr/local/{bin,libexec,share} > old.txt
docker run nextstrain/base:branch-victorlin-organize-dockerfile ls -lR --time-style='+' /usr/local/{bin,libexec,share} > new.txt
diff old.txt new.txt
# no diff!

@victorlin victorlin merged commit fefad41 into master Oct 14, 2022
@victorlin victorlin deleted the victorlin/organize-dockerfile branch October 14, 2022 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants