generated from Luis/nextjs-python-web-template
Finished README for backend #63
@@ -33,6 +33,63 @@ And then run the docker file by executing:
|
|||||||
docker run -p 127.0.0.1:2979:2979 clan-docker:latest
|
docker run -p 127.0.0.1:2979:2979 clan-docker:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- To change parameters in the generated docker image edit the file :
|
||||||
|
[flake-module.nix at line 22](flake-module.nix)
|
||||||
|
- Documentation on `dockerTools.buildImage` you can find here: https://nix.dev/tutorials/nixos/building-and-running-docker-images.html
|
||||||
|
|
||||||
|
## Docker build with UI changes
|
||||||
|
|
||||||
|
If changes to the UI have been made, and you want them to propagate to the docker container edit the file: [../ui/nix/ui-assets.nix](../ui/nix/ui-assets.nix).
|
||||||
|
This is where a release version of the frontend is downloaded and integrated into the cli and the docker build. To do this first execute
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix build .#ui --out-link ui-release
|
||||||
|
```
|
||||||
|
|
||||||
|
Make a tarball out of it called `ui-assets.tar.gz`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tar -czvf ui-assets.tar.gz ui-release/lib/node_modules/clan-ui/out/
|
||||||
|
```
|
||||||
|
|
||||||
|
Upload ui-assets.tar.gz to gitlab. To get the `GITLAB_TOKEN` go to [repo access tokens](https://git.tu-berlin.de/internet-of-services-lab/service-aware-network-front-end/-/settings/access_tokens) and generate one. Then execute
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export GITLAB_TOKEN="<your-access-token>"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
|
||||||
|
--upload-file ./ui-assets.tar.gz \
|
||||||
|
"https://git.tu-berlin.de/api/v4/projects/internet-of-services-lab%2Fservice-aware-network-front-end/packages/generic/ui-assets/1.0.0/ui-assets.tar.gz"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can find your uploaded package at the [package registry](https://git.tu-berlin.de/internet-of-services-lab/service-aware-network-front-end/-/packages)
|
||||||
|
|
||||||
|
And export the download url into a variable:
|
||||||
|
|
||||||
|
```
|
||||||
|
export url="https://git.tu-berlin.de/api/v4/projects/internet-of-services-lab%2Fservice-aware-network-front-end/packages/generic/ui-assets/1.0.0/ui-assets.tar.gz"
|
||||||
|
```
|
||||||
|
|
||||||
|
Now execute the command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat > "../ui/nix/ui-assets.nix" <<EOF
|
||||||
|
{ fetchzip }:
|
||||||
|
fetchzip {
|
||||||
|
url = "$url";
|
||||||
|
sha256 = "$(nix-prefetch-url --unpack $url)";
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
And now build the docker image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix build .#clan-docker
|
||||||
|
```
|
||||||
|
|
||||||
# Uploading a Docker Image
|
# Uploading a Docker Image
|
||||||
|
|
||||||
Login to the tu docker image server
|
Login to the tu docker image server
|
||||||
@@ -76,6 +133,70 @@ For the tests we automatically generate a python client for the API endpoints. T
|
|||||||
This will replace the folder
|
This will replace the folder
|
||||||
`tests/openapi_client`.
|
`tests/openapi_client`.
|
||||||
|
|
||||||
|
# Adding dependencies
|
||||||
|
|
||||||
|
**Dependency Management**: We use the [Nix package manager](https://nixos.org/) to manage dependencies and ensure reproducibility, making your development process more robust.
|
||||||
|
|
||||||
|
To add dependencies edit the file [default.nix](default.nix)
|
||||||
|
|
||||||
|
To search for a python dependency named "request" execute:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix search nixpkgs#pythonPackages request
|
||||||
|
```
|
||||||
|
|
||||||
|
Add the depdendency at the top of the file
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
, mydep # <--- Add here
|
||||||
|
, websockets
|
||||||
|
, broadcaster
|
||||||
|
, aenum
|
||||||
|
, dateutil
|
||||||
|
, urllib3
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
[...]
|
||||||
|
```
|
||||||
|
|
||||||
|
Add them into this array if they are a python dependency
|
||||||
|
|
||||||
|
```nix
|
||||||
|
dependencies = [
|
||||||
|
argcomplete
|
||||||
|
fastapi
|
||||||
|
uvicorn
|
||||||
|
sqlalchemy
|
||||||
|
websockets
|
||||||
|
broadcaster
|
||||||
|
mydep # <--- Add here
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
To search for a binary dependency named "firefox" execute:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix search nixpkgs firefox
|
||||||
|
```
|
||||||
|
|
||||||
|
Runtime dependency add them into this array:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
runtimeDependencies = [
|
||||||
|
bash
|
||||||
|
nix
|
||||||
|
fakeroot
|
||||||
|
zbar
|
||||||
|
git
|
||||||
|
mypy
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
# Development environment
|
||||||
|
|
||||||
|
The development environment created by `nix develop` or automatically by `direnv` is located at [shell.nix](shell.nix). The `shellHook` variable execute bash code.
|
||||||
|
|
||||||
# API Documentation
|
# API Documentation
|
||||||
|
|
||||||
Api documentation can be found in the folder `pkgs/clan-cli/tests/openapi_client/docs/`
|
Api documentation can be found in the folder `pkgs/clan-cli/tests/openapi_client/docs/`
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{ age
|
{ lib
|
||||||
, lib
|
|
||||||
, argcomplete
|
, argcomplete
|
||||||
, fastapi
|
, fastapi
|
||||||
, uvicorn
|
, uvicorn
|
||||||
@@ -15,23 +14,17 @@
|
|||||||
, python3
|
, python3
|
||||||
, runCommand
|
, runCommand
|
||||||
, setuptools
|
, setuptools
|
||||||
, sops
|
|
||||||
, stdenv
|
, stdenv
|
||||||
, wheel
|
, wheel
|
||||||
, fakeroot
|
, fakeroot
|
||||||
, rsync
|
|
||||||
, ui-assets
|
, ui-assets
|
||||||
, bash
|
, bash
|
||||||
, sshpass
|
|
||||||
, zbar
|
, zbar
|
||||||
, tor
|
|
||||||
, git
|
, git
|
||||||
, nixpkgs
|
, nixpkgs
|
||||||
, makeDesktopItem
|
, makeDesktopItem
|
||||||
, copyDesktopItems
|
, copyDesktopItems
|
||||||
, qemu
|
|
||||||
, gnupg
|
, gnupg
|
||||||
, e2fsprogs
|
|
||||||
, mypy
|
, mypy
|
||||||
, sqlalchemy
|
, sqlalchemy
|
||||||
, websockets
|
, websockets
|
||||||
@@ -73,17 +66,9 @@ let
|
|||||||
bash
|
bash
|
||||||
nix
|
nix
|
||||||
fakeroot
|
fakeroot
|
||||||
openssh
|
|
||||||
sshpass
|
|
||||||
zbar
|
zbar
|
||||||
tor
|
|
||||||
age
|
|
||||||
rsync
|
|
||||||
sops
|
|
||||||
git
|
git
|
||||||
mypy
|
mypy
|
||||||
qemu
|
|
||||||
e2fsprogs
|
|
||||||
];
|
];
|
||||||
|
|
||||||
runtimeDependenciesAsSet = builtins.listToAttrs (builtins.map (p: lib.nameValuePair (lib.getName p.name) p) runtimeDependencies);
|
runtimeDependenciesAsSet = builtins.listToAttrs (builtins.map (p: lib.nameValuePair (lib.getName p.name) p) runtimeDependencies);
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# cLan - awesome UI
|
# Web UI
|
||||||
|
|
||||||
|
**Dependency Management**: We use the [Nix package manager](https://nixos.org/) to manage dependencies and ensure reproducibility, making your development process more robust.
|
||||||
|
|
||||||
The files in `src/api` are autogenerated from the openapi.json. The openapi.json comes from the backend, from fastapi which autogenerates the openapi.json file from the python code.
|
The files in `src/api` are autogenerated from the openapi.json. The openapi.json comes from the backend, from fastapi which autogenerates the openapi.json file from the python code.
|
||||||
|
|
||||||
@@ -16,10 +18,24 @@ npm run dev
|
|||||||
|
|
||||||
To build the release version execute
|
To build the release version execute
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix build .#ui
|
||||||
|
```
|
||||||
|
|
||||||
|
you can find the output in your current working directory at a symlink called `result`
|
||||||
|
The actual web files served by the web server are located in
|
||||||
|
`result/lib/node_modules/clan-ui/out`
|
||||||
|
|
||||||
|
You can also build it directly in you dev environment. Notice however that this will clutter your directory. The out directory is directly in you working dir.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Development environment
|
||||||
|
|
||||||
|
The development environment created by `nix develop` or automatically by `direnv` is located at [shell.nix](shell.nix). The `shellHook` variable executes bash code.
|
||||||
|
|
||||||
## Updating dependencies
|
## Updating dependencies
|
||||||
|
|
||||||
After changing dependencies with
|
After changing dependencies with
|
||||||
@@ -35,7 +51,3 @@ The prettier tailwind class sorting is not yet working properly with our devShel
|
|||||||
To sort classnames manually:
|
To sort classnames manually:
|
||||||
|
|
||||||
`cd /clan-core/pkgs/ui/`
|
`cd /clan-core/pkgs/ui/`
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
Sometimes new endpoints don't appear in `src/api`. Delete the `ui/openapi.json` file and execute `direnv reload`
|
|
||||||
|
|||||||
Reference in New Issue
Block a user