Compare commits
No commits in common. "main" and "0.1.1-c.1" have entirely different histories.
5 changed files with 4 additions and 77 deletions
|
@ -56,37 +56,3 @@ jobs:
|
||||||
run: pip install twine
|
run: pip install twine
|
||||||
- name: Upload package to registry
|
- name: Upload package to registry
|
||||||
run: python -m twine upload --repository-url ${{ secrets.REPOSITORY_URL }} -u ${{ secrets.TWINE_DEPLOY_USER }} -p ${{ secrets.TWINE_DEPLOY_PASSWORD }} dist/*
|
run: python -m twine upload --repository-url ${{ secrets.REPOSITORY_URL }} -u ${{ secrets.TWINE_DEPLOY_USER }} -p ${{ secrets.TWINE_DEPLOY_PASSWORD }} dist/*
|
||||||
|
|
||||||
build-and-push-container:
|
|
||||||
needs: [ "publish-artifacts" ]
|
|
||||||
runs-on: dind
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
- name: Log into Docker Package Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: forgejo.neshweb.net
|
|
||||||
username: ${{ secrets.FORGEJO_USERNAME }}
|
|
||||||
password: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
- name: Build and push to Docker Package Registry
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
build-args: |
|
|
||||||
PACKAGE_VERSION=${{ github.ref_name }}
|
|
||||||
push: true
|
|
||||||
tags: forgejo.neshweb.net/firq/dockge-cli:${{ github.ref_name }}
|
|
||||||
|
|
||||||
release:
|
|
||||||
needs: [ build-and-push-container, publish-artifacts ]
|
|
||||||
if: success()
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- name: Release New Version
|
|
||||||
uses: actions/forgejo-release@v1
|
|
||||||
with:
|
|
||||||
direction: upload
|
|
||||||
url: https://forgejo.neshweb.net
|
|
||||||
release-dir: release
|
|
||||||
token: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
tag: ${{ github.ref_name }}
|
|
|
@ -1,4 +0,0 @@
|
||||||
FROM forgejo.neshweb.net/ci-docker-images/python-neshweb:3.11
|
|
||||||
|
|
||||||
ARG PACKAGE_VERSION=0.1.0
|
|
||||||
RUN pip install dockge-cli==${PACKAGE_VERSION}
|
|
38
README.md
38
README.md
|
@ -18,50 +18,16 @@ In the end, this is the current result that works pretty well for my understandi
|
||||||
|
|
||||||
Install it from the custom package index using
|
Install it from the custom package index using
|
||||||
|
|
||||||
```shell
|
```
|
||||||
pip install --extra-index-url https://forgejo.neshweb.net/api/packages/Firq/pypi/simple/ dockge-cli
|
pip install --extra-index-url https://forgejo.neshweb.net/api/packages/Firq/pypi/simple/ dockge-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternativly, install it using this repository. When installing for development, make sure to install with the additional dependencies
|
Alternativly, install it using this repository. When installing for development, make sure to install with the additional dependencies
|
||||||
|
|
||||||
```shell
|
```
|
||||||
pip install -e .[lint,typing]
|
pip install -e .[lint,typing]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Call the CLI using `dockge-cli` or `dockge`.
|
Call the CLI using `dockge-cli` or `dockge`.
|
||||||
|
|
||||||
```shell
|
|
||||||
usage: dockge_cli [-h] [--version] {host,login,logout,list,status,restart,start,stop,down,update,exit,help}
|
|
||||||
|
|
||||||
CLI interface for interacting with Dockge
|
|
||||||
|
|
||||||
positional arguments:
|
|
||||||
{host,login,logout,list,status,restart,start,stop,down,update,exit,help}
|
|
||||||
|
|
||||||
options:
|
|
||||||
-h, --help show this help message and exit
|
|
||||||
--version show program's version number and exit
|
|
||||||
```
|
|
||||||
|
|
||||||
Help for each individual command can be invoked by calling `dockge-cli help <command>`
|
|
||||||
|
|
||||||
## The magic behind this
|
|
||||||
|
|
||||||
Generally, this makes use of the underlying Websockets API that the Dockge frontend uses to communicate with the server. By analyzing the traffic and looking into the codebase, I was able to reverse most of the packets that are being sent. This allows me to then contruct, send and receive my own packets, making the whole thing work.
|
|
||||||
|
|
||||||
There are some things that need to be taken into account for this: For one, dockge uses socket.io for the websocket communication. This meant I had to find the corresponding socket.io version to get the correct version of python-socketio. In addition, I had to find out how the authorization mechanism behind this works.
|
|
||||||
|
|
||||||
After finishing up the first prototype, the workings are as follows:
|
|
||||||
|
|
||||||
1. A websocket session is established using socket.io - this happens automatically
|
|
||||||
2. After the session is ready, the `login` command is sent together with a provided username and password
|
|
||||||
3. Once the CLI is authorized, the selected command is sent
|
|
||||||
4. The CLI waits for any response values and exits once the command has executed successfully
|
|
||||||
|
|
||||||
To provide a smooth experience, both the credentials and the remote host URI are stored on disk. just like the `docker` cli, the credentials are not encrypted, meaning it is advised to either clear the credentials after use OR to use the `--username` and `--password` parameters. This is especially recommended for CI applications.
|
|
||||||
|
|
||||||
## Known issues
|
|
||||||
|
|
||||||
This CLI does not work when Mullvad is used, as Mullvad actively blocks port forwarding (which python-socketio uses)
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class DockgeConnection:
|
||||||
Connect to the websocket
|
Connect to the websocket
|
||||||
"""
|
"""
|
||||||
# Dockge uses Socket.io for the websockets, so this URI and params are always the same
|
# Dockge uses Socket.io for the websockets, so this URI and params are always the same
|
||||||
self._sio.connect(f"https://{self._host}/socket.io/")
|
self._sio.connect(f"https://{self._host}/socket.io/", transports=['websocket'])
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
[project]
|
[project]
|
||||||
name = "dockge_cli"
|
name = "dockge_cli"
|
||||||
version = "0.1.2"
|
version = "0.1.1-c.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pyyaml~=6.0.1",
|
"pyyaml~=6.0.1",
|
||||||
"pydantic~=2.8.0",
|
"pydantic~=2.8.0",
|
||||||
"requests~=2.32.3",
|
|
||||||
"python-socketio~=5.11.3",
|
"python-socketio~=5.11.3",
|
||||||
"websocket-client~=1.8.0",
|
"websocket-client~=1.8.0",
|
||||||
"tabulate ~=0.9.0",
|
"tabulate ~=0.9.0",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue