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

fix(dockerfile): improve documentation and change working directory #4

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

iainsproat
Copy link
Contributor

@iainsproat iainsproat commented Nov 1, 2023

  • Adds inline commentary to the Dockerfile to help new users understand it.
  • Installs code at /home/speckle to prevent collisions with files & directories in the root (/) directory, and changes the working directory to /home/speckle so the command remains the same.
  • Updates the README and provides instructions for building and testing the docker image locally

- Speckle Automate runs the Function as a non-root user
- For testing purposes, it is best that the non-root user exist in the Docker image so it can be run as that user
- Adds inline commentary to the Dockerfile
- Installs code at /home/speckle to prevent collisions with files & directories in the root (/) directory
- Updates the README and provides instructions for building and testing the docker image locally
@iainsproat
Copy link
Contributor Author

iainsproat commented Nov 1, 2023

I can't get pytest to run properly in the container. At the moment it complains it cannot be found.

Command not found: pytest

If I install pytest in the image via pip, and run it:

docker run --rm --user speckle:speckle speckle_automate_python_example poetry run pytest

this results in the following error:

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_function.py ____________________
ImportError while importing test module '/home/speckle/tests/test_function.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_function.py:18: in <module>
    from main import FunctionInputs, automate_function
E   ModuleNotFoundError: No module named 'main'
=========================== short test summary info ============================
ERROR tests/test_function.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.49s ===============================

Copy link

@iainsproat iainsproat changed the title fix(dockerfile): create a non-root user fix(dockerfile): improve documentation Nov 2, 2023
@iainsproat iainsproat changed the title fix(dockerfile): improve documentation fix(dockerfile): improve documentation and change working directory Nov 2, 2023
@iainsproat iainsproat merged commit 2b8bbd6 into main Nov 2, 2023
1 check passed
@iainsproat iainsproat deleted the iain/add-non-root-user-for-testing branch November 2, 2023 12:33
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