-
Notifications
You must be signed in to change notification settings - Fork 8
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 issue for building docker container #91
Conversation
…or building container
Note that ths proposition will not work directly due to missing credentials for ghcr. You must update them @nennigb. |
@@ -13,24 +13,25 @@ jobs: | |||
name: 'Build amc2moodle container' | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: actions/checkout@v4 |
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.
I suggest @main
instead of @v4
for all actions.
Since the version doesn't matter, @main
allow to use always the last version.
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.
.vscode/settings.json
Outdated
"-p", | ||
"test_*.py" | ||
], | ||
"python.testing.pytestEnabled": false, |
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.
Is this file really required ?
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.
probably not with the future new version using pyproject.toml (vscode will read it to identify tests)
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.
I removed it in future version see #90
amc2moodle/utils/misc.py
Outdated
return cls | ||
return decorate | ||
|
||
def decorator_set_cwd(directory): |
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.
Perhaps there are more pythonic way to do this ?
Defined in unittest famework ?
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.
I don't know but it works well :-)
python3-venv \ | ||
git && \ | ||
apt clean &&\ | ||
rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
|
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.
better to use apt-get (to avoid WARNING: apt does not have a stable CLI interface. Use with caution in scripts.)
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.
fixed
RUN pip3 install -U pip && \ | ||
pip3 install . | ||
RUN mkdir -p ${VENVDIR} && \ | ||
python -m venv ${VENVDIR} |
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 installing the package in a venv ?
No problem with that, I am just curious ;-)
Doesn't seems to create problem.
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.
in order to avoid "error: externally-managed-environment" when use the system python/pip
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.
ok :-)
docker/Dockerfile
Outdated
python3-venv \ | ||
git && \ | ||
apt clean &&\ | ||
rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
|
||
# move policy file | ||
RUN mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.off |
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.
On my tests, docker install imageMagick 7 thus the path is wrong.
In interactive session it seems to work without this line. The default policy has changed in v7, perhaps we could just comment this line.
To see the policy in v7
magick identify -list policy
https://imagemagick.org/script/security-policy.php
Normally it should be catch in the unittests with the tinymonk.pdf
file.
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.
fixed
python -m amc2moodle.moodle2amc.test | ||
|
||
|
||
RUN python -m pytest --pyargs amc2moodle |
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.
CI will fail until
[project.optional-dependencies]
test = ["pytest", "pytest-cov[all]"]
will be merged into the master branch used for docker build.
We could merge by the way.
pyproject.toml
Outdated
@@ -26,6 +26,10 @@ dependencies = [ | |||
] | |||
requires-python='>=3.8' | |||
|
|||
[project.optional-dependencies] | |||
test = ["pytest", "pytest-cov[all]"] | |||
lint = [ "black", "flake8"] |
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.
By default
https://hatch.pypa.io/1.13/config/internal/static-analysis/
hatch use ruff: https://github.com/astral-sh/ruff, 99.9% compatible with black.
Not sure we need this line: lint = [ "black", "flake8"]
Perhaps we could also configure ruff or have a discussion on rules
hatch default is line 120, which looks good for me. It could be put in the pyproject.toml
to avoid changes
[tool.ruff]
# Allow lines to be as long as 120.
line-length = 120
I prefer simple quotes which is the present convention and looks less bulky.
[tool.ruff.format]
quote-style = "single"
If we choose ruff, we need to modify the readme.
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.
I add it
Another thing to fix (one day) would be the log that grows indefinitely if the docker is not stopped. |
* update pyproject.toml to integrate the use of ruff as code analyser * update Docker's files (Dockerfile, README, bash script) to ensure logrotation and a few fixes * many improvments of typos * update workflow to use @main on actions
I integrate a new management of the logs for |
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.
For me it goods. You can have a look on the detailed the comments.
I let you merge when you are ready.
@@ -15,19 +15,28 @@ The container proposes to mount two volumes: | |||
- `/tmp/work` (**mandatory mount**) that must be link to a specific folder on the host computer | |||
- `/tmp/daemon` (optional mount) that store the log file of the daemon | |||
|
|||
For instance, the container can be run in CLI (in detached mode) with the following command: | |||
For instance, the container can be run in CLI (in detached mode) with the following command (*by relacing `DIRA` and if necessary `DIRB`): |
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.
typo "replacing"
In case of permission issue to mount folder(s), consider adding option `--user "$(id -u):$(id -g)"` such as the running command is: | ||
|
||
``` | ||
docker run --name amc2moodle --user "$(id -u):$(id -g)" -d -v "DIRA:/tmp/work" -v "DIRB:/tmp/daemon" ghcr.io/nennigb/amc2moodle |
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.
thanks :-)
|
||
#log manage | ||
now=$(date +"%Y-%m-%d_%H-%M-%s") | ||
mkdir -p ${LOG_DIR} | ||
LOGFILE=${LOG_DIR}/${now}_autorun.log | ||
init_logrotate | ||
run_logrotate & | ||
|
||
{ |
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.
Seems goods. I run test and log looks good. The rotation also works well.
Just a question the modification with f strings were automatic or manual ? |
I ran |
Many improvements and updates on