Skip to content

docker: add example Dockerfile #2844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM python:3.7

# Better movement with [Ctrl + →] and [Ctrl + ←]
ENV INPUTRC=/etc/inputrc

RUN set -ex \
&& echo '"\e[1;5C": forward-word' >> /etc/inputrc \
&& echo '"\e[1;5D": backward-word' >> /etc/inputrc

Comment on lines +3 to +9
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't quite understand what this is for and why this is needed in the docker file.

Copy link
Author

Choose a reason for hiding this comment

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

Usability. If you get into the shell, you won't be able to use Ctrl + arrows to move between words, for me it is annoying, that's why I added this.

Copy link
Contributor

Choose a reason for hiding this comment

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

again I think this is on the same level as zstyle - something that is generic shell/system-related and not about dvc

# Set working directory.
# Mount your project under the same path.
WORKDIR /usr/src

Comment on lines +10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

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

Using /usr/src seems pretty strange. I think it is used in some systems (e.g. slackware?) to store actual sources.

Copy link
Author

Choose a reason for hiding this comment

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

It could be whatever you want, I've seen some Dockerfiles using /usr/src since it is expected that you'll only put one source into it.

# Install useful programs
RUN apt-get update -y && apt-get install -y \
less \
git
Comment on lines +15 to +17
Copy link
Contributor

Choose a reason for hiding this comment

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

What's up with this odd formatting?

Copy link
Author

Choose a reason for hiding this comment

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

Readability, you can see at first glance what packages are being installed.


# Install DVC, supporting all remotes
RUN pip install "dvc[all]"

# Enable autocompletion scripts for DVC
RUN wget \
-O /etc/bash_completion.d/dvc \
https://github.com/raw/iterative/dvc/master/scripts/completion/dvc.bash
Comment on lines +23 to +25
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand why docker image needs bash completion. And if it does, why not zsh as well?

Copy link
Author

Choose a reason for hiding this comment

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

Usability. We opted to use Bash instead of Zsh. I don't see the point of using both.


# Add a user to run DVC
ARG USER_ID=1000
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose you are doing this so that files created by dvc are not owned by root, right? If so, now they are going to be owned by UID 1000, which is absolutely not guaranteed to match your current user on the host.

Copy link
Author

Choose a reason for hiding this comment

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

The user must build the image with their UID, see the description of the issue:
#2844 (comment)

RUN useradd --create-home -u ${USER_ID} dvc
USER dvc