cockpit-docker icon indicating copy to clipboard operation
cockpit-docker copied to clipboard

Compatibility with CentOS 8 Stream and docker-ce?

Open edmondsiu0 opened this issue 4 years ago • 8 comments

I have compiled this and moved the dist into my cockpit directory /usr/share/cockpit.

However, it is not working with the following error:

Uncaught ReferenceError: jQuery is not defined
    at Object.jquery (docker.js:216946)
    at __webpack_require__ (docker.js:20)
    at Module../pkg/docker/containers.js (docker.js:209491)
    at __webpack_require__ (docker.js:20)
    at Object.0 (docker.js:216923)
    at __webpack_require__ (docker.js:20)
    at docker.js:84
    at docker.js:87

Looking at the docker/index.html file, it is expecting a jquery.js file under ../base1/jquery.js, but this file doesn't exist in this installation of cockpit.

# grep -n -i jquery docker/index.html -A5 -B5
23-    <title translate="yes">Containers</title>
24-    <meta charset="utf-8">
25-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
26-    <link href="../base1/patternfly.css" type="text/css" rel="stylesheet">
27-    <link href="docker.css" type="text/css" rel="stylesheet" id="term-style">
28:    <script src="../base1/jquery.js"></script>
29-    <script src="../base1/cockpit.js"></script>
30-    <script src="../*/po.js"></script>
31-    <script src="docker.js"></script>
32-</head>
33-<body class="pf-m-redhat-font" hidden>
# ls -lah | grep -i jquery
#

I'm not much of a web developer, any idea how this could be rectified or worked around?

Edit:

cockpit package:

# yum info cockpit
Last metadata expiration check: 2:29:47 ago on Tue Feb  2 12:20:11 2021.
Installed Packages
Name         : cockpit
Version      : 235
Release      : 1.el8
Architecture : x86_64
Size         : 56 k
Source       : cockpit-235-1.el8.src.rpm
Repository   : @System
From repo    : anaconda
Summary      : Web Console for Linux servers
URL          : https://cockpit-project.org/
License      : LGPLv2+
Description  : The Cockpit Web Console enables users to administer GNU/Linux servers using a
             : web browser.
             :
             : It offers network configuration, log inspection, diagnostic reports, SELinux
             : troubleshooting, interactive command-line sessions, and more.

Environment:

# cat /etc/os-release
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

edmondsiu0 avatar Feb 02 '21 13:02 edmondsiu0

I have found this jquery.min.js.gz from an old installation of cockpit, and I sticked it into /usr/share/cockpit/base1/jquery.min.js.gz, and that was enough to get this module to work.

Don't know if it's better to bundle this jquery.min.js.gz within this module, if the latest cockpit doesn't supply this file, or whether that's going to cause other issues....

edmondsiu0 avatar Feb 02 '21 13:02 edmondsiu0

Hey,

I don't have a Centos 8 install ready, so I can't validate if this works or not. I guess I'll setup a docker container to check this out :-)

Let me get back on this when I have that up and running

Xantios avatar Feb 02 '21 13:02 Xantios

I can report that if you grab the latest jQuery from their site, compress it with gzip, and drop it in the global directory, it works.

https://jquery.com/download/

I'm using a fresh debian buster install.

HoECoder avatar Mar 04 '21 19:03 HoECoder

Did you run the install script at all? it should pull in jQuery from npm and get build by web pack.

I tried this on ubuntu-latest and it worked like a charm.

the readme is updated quite recently. check it out :-)

Xantios avatar Mar 04 '21 23:03 Xantios

@Xantios I did, ran the script with one change; I swapped the symlink to the user directory to symlink to the global:

# Link as user module
mkdir -p ~/.local/share/cockpit
#ln -s $PWD/dist/docker $HOME/.local/share/cockpit/docker
sudo ln -s $PWD/dist/docker /usr/share/cockpit/docker

I'm not the best at Node.js, but I think the way cockpit has it setup is that it is looking for assets in /usr/share/cockpit/base1/.

HoECoder avatar Mar 05 '21 13:03 HoECoder

This is on a fresh debian 10 box with the latest docker out of the repo. My copy of cockpit is out of the buster backports.

HoECoder avatar Mar 05 '21 13:03 HoECoder

Can you please try to run the script as is?

if that works you can move the plugin anywhere your heart desires afterwards, but just to make sure there isn't a weird bug in webpack :-)

I --think-- the path is hardcoded on one or more places (and this is the easiest way to make sure of that)

Xantios avatar Mar 11 '21 15:03 Xantios

I had the same problem on Fedora 34 Server when running the unmodified install script. Can confirm that this fixes it:

I can report that if you grab the latest jQuery from their site, compress it with gzip, and drop it in the global directory, it works.

https://jquery.com/download/

I'm using a fresh debian buster install.

romano21A avatar Jun 27 '21 15:06 romano21A