-
Notifications
You must be signed in to change notification settings - Fork 632
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
Feature/add docker compose #1250
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1250 +/- ##
==========================================
+ Coverage 91.24% 91.26% +0.02%
==========================================
Files 139 139
Lines 9768 9768
==========================================
+ Hits 8913 8915 +2
+ Misses 855 853 -2
Continue to review full report at Codecov.
|
Hi @davidbuniat since we are gonna use this compose for development workflow I recommend the following approach:
FROM python:3.8-slim
RUN apt-get -y update && \
apt-get -y install git wget build-essential python-setuptools python3-dev libjpeg-dev libpng-dev zlib1g-dev && \
apt install build-essential
RUN mkdir /app
ADD ./hub/requirements /app/hub/requirements
WORKDIR /app
ENV PYTHONPATH="/app/Hub:$PYTHONPATH"
RUN pip install -r hub/requirements/requirements.txt && \
pip install -r hub/requirements/common.txt && \
pip install -r hub/requirements/tests.txt && \
pip install -r hub/requirements/plugins.txt
version: '2'
x-creds: &global-vars
environment:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
- GOOGLE_APPLICATION_CREDENTIALS=/root/.config/gcloud/gcs.json
- ACTIVELOOP_HUB_PASSWORD
services:
local:
build:
context: ../.
dockerfile: ./bin/Dockerfile.dev
volumes:
- ../:/app
command: >
bash -c "python setup.py install && python3 -m pytest -x --local"
complete:
build:
context: ../.
dockerfile: ./bin/Dockerfile.dev
<<: *global-vars
volumes:
- ~/.config/gcloud/gcs.json:/root/.config/gcloud/gcs.json
- ../:/app
command: >
bash -c "python setup.py install && python3 -m pytest -x --local --s3 --gcs --hub-cloud --ignore-glob=buH/*" |
I like this approach more, but I don't see why |
It will make sure that the installed package is always the latest one. You can also use the 'pip3 install -e .' command. Let's say a developer changed the source code on his local environment after cloning the repo. He had already done building the image earlier after cloning the repo. Having it in the start script will always take the latest version of the package. Tbh it is just a hack so that developer don't have to pass '--build' argument to docker compose all the time. |
@gautamkrishnar exactly that case is covered with install being in dockerfile, because you are also mapping the volume. Any change after docker is built will be reflected in the python package. I do my development like that. Sometimes I often rerun the docker and there is no need to install the package every time. |
@mccrearyd those creds do not get stored inside docker, they are environment variables that are passed when you run docker-compose up. If you have stored the environment variables inside Dockerfile, then they would be stored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address comments, ping for quick rereview
bin/Dockerfile.dev
Outdated
RUN pip install -r hub/requirements/requirements.txt && \ | ||
pip install -r hub/requirements/common.txt && \ | ||
pip install -r hub/requirements/tests.txt && \ | ||
pip install -r hub/requirements/plugins.txt | ||
|
||
RUN pip3 install -e . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using pip3 and pip could break things if we change FROM container
also, if you run pip install -e . first then you only need to install tests/plugins.
finally, we need to remove requirements.txt (it's useless). we should only have "common.txt"
bin/Dockerfile.dev
Outdated
WORKDIR /app | ||
|
||
ENV PYTHONPATH="/app/Hub:$PYTHONPATH" | ||
RUN ls hub/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ls?
@mccrearyd in addition to plugins.txt we still need install tests.txt if we want to run pytest inside docker |
🚀 🚀 Pull Request
Checklist:
coverage-rate
upChanges
Modified the dockerfile for complete local environment and added a docker-compose file for easy parameters