Skip to content
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

[Question] sm-docker zips and uploads the current dir, not the target dir? #3

Open
athewsey opened this issue Oct 2, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@athewsey
Copy link

athewsey commented Oct 2, 2020

From my investigations into #2, I saw that sm-docker is zipping and uploading the current folder, not the target folder, when a target is given. E.g:

sm-docker build ./docker
# Uploads all of ./ (not just ./docker) to S3

Is this expected and deliberate for some reason? If you have lots of other stuff in your folder it can make for a significantly slower wait than the (also working) cd ./docker && sm-docker build .

@w601sxs
Copy link

w601sxs commented Nov 3, 2020

also if the current dir does not have a dockerfile, it will still spin off the codebuild job and fail during the build stage. Suggest checking for a dockerfile first before starting the process

@jaipreet-s
Copy link
Contributor

jaipreet-s commented Dec 15, 2020

Is this expected and deliberate for some reason?

Hi @athewsey, yes this is expected. See

with tempfile.TemporaryFile() as tmp:
with zipfile.ZipFile(tmp, "w") as zip:
# Zip all files in "dir"
for dirname, _, filelist in os.walk("."):
for file in filelist:
zip.write(f"{dirname}/{file}")
# Add buildspec.yml
and this is also explained in the README https://github.com/aws-samples/sagemaker-studio-image-build-cli/blame/master/README.md#L31.

However, your point is valid, as the docker CLI honors the target directory and not the current directory. For e.g., docker build examples/basic_build works without having to "cd" into the directory.

@jaipreet-s
Copy link
Contributor

jaipreet-s commented Dec 15, 2020

@w601sxs - Good call, that's a great enhancement.

@jaipreet-s jaipreet-s added the enhancement New feature or request label Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants