Installing Jupyter in 1.22-rootless #13036

Closed
opened 2025-11-02 10:28:20 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @graelo on GitHub (May 27, 2024).

Description

Hi, amazing release, thanks!

I used to add Jupyter inside a custom rootless image following the instructions in 98751108b1/docs/content/administration/external-renderers.en-us.md (L44-L46)

However starting with 1.22.0 this is not possible anymore because of some permissions issues during the docker build process. It used to work flawlessly in 1.21 and previous versions. See error below.

When appropriate, can you please update the instructions or fix the permissions issue in the 1.22-rootless image?

Thanks!

error returned during docker build process (used to work with <1.22):
  => ERROR [3/5] RUN pip3 install --upgrade pip                                                                                                         1.1s
------
 > [3/5] RUN pip3 install --upgrade pip:
0.888 WARNING: The directory '/var/lib/gitea/git/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
0.893 error: externally-managed-environment
0.893
0.893 × This environment is externally managed
0.893 ╰─>
0.893     The system-wide python installation should be maintained using the system
0.893     package manager (apk) only.
0.893
0.893     If the package in question is not packaged already (and hence installable via
0.893     "apk add py3-somepackage"), please consider installing it inside a virtual
0.893     environment, e.g.:
0.893
0.893     python3 -m venv /path/to/venv
0.893     . /path/to/venv/bin/activate
0.893     pip install mypackage
0.893
0.893     To exit the virtual environment, run:
0.893
0.893     deactivate
0.893
0.893     The virtual environment is not deleted, and can be re-entered by re-sourcing
0.893     the activate file.
0.893
0.893     To automatically manage virtual environments, consider using pipx (from the
0.893     pipx package).
0.893
0.893 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
0.893 hint: See PEP 668 for the detailed specification.
------
Dockerfile:8
--------------------
   6 |     # install any other package you need for your external renderers
   7 |
   8 | >>> RUN pip3 install --upgrade pip
   9 |     RUN pip3 install -U setuptools
  10 |     RUN pip3 install jupyter docutils
--------------------
ERROR: failed to solve: process "/bin/sh -c pip3 install --upgrade pip" did not complete successfully: exit code: 1

Gitea Version

1.22

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Linux x86-64

How are you running Gitea?

Here is my Dockerfile

FROM gitea/gitea:1.22.0-rootless

USER 0:0

RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc py-pip python3-dev py3-pip py3-pyzmq
# install any other package you need for your external renderers

RUN pip3 install --upgrade pip
RUN pip3 install -U setuptools
RUN pip3 install jupyter docutils

USER 1000:1000

Database

None

Originally created by @graelo on GitHub (May 27, 2024). ### Description Hi, amazing release, thanks! I used to add Jupyter inside a custom rootless image following the instructions in https://github.com/go-gitea/gitea/blob/98751108b11dc748cc99230ca0fc1acfdf2c8929/docs/content/administration/external-renderers.en-us.md?plain=1#L44-L46 However starting with 1.22.0 this is not possible anymore because of some permissions issues during the docker build process. It used to work flawlessly in 1.21 and previous versions. See error below. When appropriate, can you please update the instructions or fix the permissions issue in the 1.22-rootless image? Thanks! <details> error returned during docker build process (used to work with <1.22): ``` => ERROR [3/5] RUN pip3 install --upgrade pip 1.1s ------ > [3/5] RUN pip3 install --upgrade pip: 0.888 WARNING: The directory '/var/lib/gitea/git/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. 0.893 error: externally-managed-environment 0.893 0.893 × This environment is externally managed 0.893 ╰─> 0.893 The system-wide python installation should be maintained using the system 0.893 package manager (apk) only. 0.893 0.893 If the package in question is not packaged already (and hence installable via 0.893 "apk add py3-somepackage"), please consider installing it inside a virtual 0.893 environment, e.g.: 0.893 0.893 python3 -m venv /path/to/venv 0.893 . /path/to/venv/bin/activate 0.893 pip install mypackage 0.893 0.893 To exit the virtual environment, run: 0.893 0.893 deactivate 0.893 0.893 The virtual environment is not deleted, and can be re-entered by re-sourcing 0.893 the activate file. 0.893 0.893 To automatically manage virtual environments, consider using pipx (from the 0.893 pipx package). 0.893 0.893 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. 0.893 hint: See PEP 668 for the detailed specification. ------ Dockerfile:8 -------------------- 6 | # install any other package you need for your external renderers 7 | 8 | >>> RUN pip3 install --upgrade pip 9 | RUN pip3 install -U setuptools 10 | RUN pip3 install jupyter docutils -------------------- ERROR: failed to solve: process "/bin/sh -c pip3 install --upgrade pip" did not complete successfully: exit code: 1 ``` </details> ### Gitea Version 1.22 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System Linux x86-64 ### How are you running Gitea? Here is my `Dockerfile` ``` FROM gitea/gitea:1.22.0-rootless USER 0:0 RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc py-pip python3-dev py3-pip py3-pyzmq # install any other package you need for your external renderers RUN pip3 install --upgrade pip RUN pip3 install -U setuptools RUN pip3 install jupyter docutils USER 1000:1000 ``` ### Database None
GiteaMirror added the type/bug label 2025-11-02 10:28:20 -06:00
Author
Owner

@wxiaoguang commented on GitHub (May 27, 2024):

Does 1.21 rootless work for you?

IIRC the recent "python" related change is "Add template linting via djlint (https://github.com/go-gitea/gitea/pull/25212)" (@silverwind), which is also in 1.21

@wxiaoguang commented on GitHub (May 27, 2024): Does 1.21 rootless work for you? IIRC the recent "python" related change is "Add template linting via djlint (https://github.com/go-gitea/gitea/pull/25212)" (@silverwind), which is also in 1.21
Author
Owner

@graelo commented on GitHub (May 27, 2024):

Yes 1.21 rootless and previous did work. (I just added this to the bug description)

@graelo commented on GitHub (May 27, 2024): Yes 1.21 rootless and previous did work. (I just added this to the bug description)
Author
Owner

@silverwind commented on GitHub (May 27, 2024):

I think this is a new check that pip added, which probably came in the latest alpine upgrade. Possible solutions as per https://stackoverflow.com/a/75696359/808699:

  • Install packages via apk (if they exist)
  • Use pipx instead of pip
  • Pass --break-system-packages

We likely need to updated these docs.

@silverwind commented on GitHub (May 27, 2024): I think this is a new check that pip added, which probably came in the latest alpine upgrade. Possible solutions as per https://stackoverflow.com/a/75696359/808699: - Install packages via apk (if they exist) - Use `pipx` instead of `pip` - Pass `--break-system-packages` We likely need to updated these docs.
Author
Owner

@wxiaoguang commented on GitHub (May 27, 2024):

OK, I think the problem is mainly caused by the alpine/pip package. See: https://github.com/pypa/pip/issues/12429 upgrade not working in Alpine 3.19

It seems that the python/pip package changed their behavior in Alpine 3.19

Gitea 1.21 uses alpine 3.18, Gitea 1.22 uses alpine 3.20, to reproduce:

FROM gitea/gitea:1.22.0-rootless

USER 0:0

RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc py-pip python3-dev py3-pip py3-pyzmq
RUN mkdir -p /var/lib/gitea/git/.cache/pip
RUN pip3 install --upgrade pip

Then you see exactly the same error message as https://github.com/pypa/pip/issues/12429

Maybe you need to figure out a proper pip-installation method for Alpine >= 3.19

@wxiaoguang commented on GitHub (May 27, 2024): OK, I think the problem is mainly caused by the alpine/pip package. See: https://github.com/pypa/pip/issues/12429 upgrade not working in Alpine 3.19 It seems that the python/pip package changed their behavior in Alpine 3.19 Gitea 1.21 uses alpine 3.18, Gitea 1.22 uses alpine 3.20, to reproduce: ``` FROM gitea/gitea:1.22.0-rootless USER 0:0 RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc py-pip python3-dev py3-pip py3-pyzmq RUN mkdir -p /var/lib/gitea/git/.cache/pip RUN pip3 install --upgrade pip ``` Then you see exactly the same error message as https://github.com/pypa/pip/issues/12429 Maybe you need to figure out a proper pip-installation method for Alpine >= 3.19
Author
Owner

@graelo commented on GitHub (May 27, 2024):

Thanks everyone, yes it works with the following:

RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc python3-dev pipx py3-pyzmq
# install any other package you need for your external renderers

RUN pipx install jupyter docutils --include-deps

Notes

  • I tried with --break-system-packages, but this is not a valid argument.
  • I had to add --include-deps otherwise the installation would not proceed.
  • The container is now running fine.
  • patch
diff --git a/Dockerfile b/Dockerfile
index e17c240..2eebb2f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,11 +2,9 @@ FROM gitea/gitea:1.22.0-rootless
 
 USER 0:0
 
-RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc py-pip python3-dev py3-pip py3-pyzmq
+RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc python3-dev pipx py3-pyzmq
 # install any other package you need for your external renderers
 
-RUN pip3 install --upgrade pip
-RUN pip3 install -U setuptools
-RUN pip3 install jupyter docutils
+RUN pipx install jupyter docutils --include-deps
 
 USER 1000:1000
@graelo commented on GitHub (May 27, 2024): Thanks everyone, yes it works with the following: ```Dockerfile RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc python3-dev pipx py3-pyzmq # install any other package you need for your external renderers RUN pipx install jupyter docutils --include-deps ``` ## Notes - I tried with `--break-system-packages`, but this is not a valid argument. - I had to add `--include-deps` otherwise the installation would not proceed. - The container is now running fine. - patch ```patch diff --git a/Dockerfile b/Dockerfile index e17c240..2eebb2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,9 @@ FROM gitea/gitea:1.22.0-rootless USER 0:0 -RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc py-pip python3-dev py3-pip py3-pyzmq +RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc python3-dev pipx py3-pyzmq # install any other package you need for your external renderers -RUN pip3 install --upgrade pip -RUN pip3 install -U setuptools -RUN pip3 install jupyter docutils +RUN pipx install jupyter docutils --include-deps USER 1000:1000 ```
Author
Owner

@silverwind commented on GitHub (May 27, 2024):

Seems good, we should update the docs with that.

@silverwind commented on GitHub (May 27, 2024): Seems good, we should update the docs with that.
Author
Owner

@graelo commented on GitHub (May 27, 2024):

Thanks again for the prompt support, and congrats for the huge work on this project.

@graelo commented on GitHub (May 27, 2024): Thanks again for the prompt support, and congrats for the huge work on this project.
Author
Owner

@wxiaoguang commented on GitHub (May 27, 2024):

-> Update pip related commands for docker #31106

@wxiaoguang commented on GitHub (May 27, 2024): -> Update pip related commands for docker #31106
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13036