diff --git a/.env.example b/.env.example index 140835d..b117477 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,5 @@ -SECRET_KEY= -NODE_ID=0 -NODE_NAME="" -# MANAGER_URL="localhost:8000" -MANAGER_URL=manager:8000 -TOKEN= -SMB_USER=amuman -SMB_PASSWORD= -SMB_URL=//..../ -SMB_MOUNT_POINT=/nas +DOMAIN=example.com +SECRET_KEY=random_string +DJANGO_SUPERUSER_EMAIL=admin@pm.me +DJANGO_SUPERUSER_USERNAME=admin +DJANGO_SUPERUSER_PASSWORD=random_string \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 15634a5..08057ad 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -30,7 +30,7 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ghcr.io/${{ github.repository }} + ghcr.io/${{ github.repository }}/frontend tags: | type=ref,event=pr type=semver,pattern={{version}} @@ -40,7 +40,7 @@ jobs: - name: Build and push image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 with: - context: . + context: ./frontend push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/flake.lock b/flake.lock deleted file mode 100644 index c9418e7..0000000 --- a/flake.lock +++ /dev/null @@ -1,27 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1707205916, - "narHash": "sha256-fmRJilYGlB7VCt3XsdYxrA0u8e/K84O5xYucerUY0iM=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "8cc79aa39bbc6eaedaf286ae655b224c71e02907", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 51f8192..0000000 --- a/flake.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - }; - - outputs = { - self, - nixpkgs, - }: let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - - fhs = pkgs.buildFHSUserEnv { - name = "fhs-shell"; - targetPkgs = pkgs: with pkgs; [micromamba zsh]; - runScript = '' - zsh -c ' - export MAMBA_ROOT_PREFIX=.mamba - eval $(micromamba shell activate env1 --shell bash) - exec zsh - ' - ''; - }; - in { - devShells.${system}.default = fhs.env; - }; -} diff --git a/justfile b/justfile index dc4c15e..b92e686 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ set dotenv-load proxy: - podman run -d --replace --tz local --pull newer \ + podman run --rm -it --replace --tz local --pull newer \ --name amuman-proxy-staging \ --network amuman-staging \ -v ./proxy/nginx.conf:/etc/nginx/conf.d/default.conf:z \ @@ -10,13 +10,13 @@ proxy: frontend: podman build ./frontend -t amuman-frontend-staging - podman run -d --replace --tz local --pull newer \ + podman run --rm -it --replace --tz local --pull newer \ --name amuman-frontend-staging \ --network amuman-staging \ amuman-frontend-staging redis: - podman run -d --replace --tz local --pull newer \ + podman run --rm -it --replace --tz local --pull newer \ --name amuman-redis-staging \ --network amuman-staging \ docker.io/redis:7.2.4-alpine3.19 @@ -24,7 +24,7 @@ redis: manager: podman build ./manager -t amuman-manager-staging - podman run -d --replace --tz local --pull newer \ + podman run --rm -it --replace --tz local --pull newer \ --name amuman-manager-staging \ --network amuman-staging \ -v ./staging:/manager \ @@ -33,6 +33,7 @@ manager: -e DJANGO_SUPERUSER_USERNAME=$DJANGO_SUPERUSER_USERNAME \ -e DJANGO_SUPERUSER_PASSWORD=$DJANGO_SUPERUSER_PASSWORD \ -e DOMAIN=$DOMAIN \ + -e REDIS_HOST=amuman-redis-staging \ amuman-manager-staging node: @@ -40,11 +41,17 @@ node: podman run --rm -it --replace --tz local --pull newer \ --name amuman-node-staging \ - --network amuman-staging \ --device=nvidia.com/gpu=all \ -v ./mock_nas:/mnt/smb \ -e MANAGER_DOMAIN=$DOMAIN \ -e NODE_NAME=staging-node-1 \ amuman-node-staging -staging: frontend redis manager proxy \ No newline at end of file +staging: frontend redis manager proxy + +kill-staging: + podman rm -f amuman-proxy-staging + podman rm -f amuman-frontend-staging + podman rm -f amuman-redis-staging + podman rm -f amuman-manager-staging + podman rm -f amuman-node-staging \ No newline at end of file diff --git a/manager/Containerfile b/manager/Containerfile index c659759..baa9747 100644 --- a/manager/Containerfile +++ b/manager/Containerfile @@ -7,12 +7,6 @@ COPY . . RUN mkdir -p /manager -ENV SECRET_KEY= -ENV DJANGO_SUPERUSER_EMAIL= -ENV DJANGO_SUPERUSER_USERNAME= -ENV DJANGO_SUPERUSER_PASSWORD= -ENV DOMAIN_URL= ENV DEBUG=FALSE -ENV REDIS_URL="amuman-redis-staging:6379" -ENTRYPOINT ["/app/staging.entrypoint.sh"] +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/manager/staging.entrypoint.sh b/manager/entrypoint.sh similarity index 100% rename from manager/staging.entrypoint.sh rename to manager/entrypoint.sh diff --git a/node/Containerfile b/node/Containerfile index 2ac652c..9b5fd1c 100644 --- a/node/Containerfile +++ b/node/Containerfile @@ -22,4 +22,4 @@ COPY . . RUN pip install . ENV SMB_MOUNT_POINT=/mnt/smb -ENTRYPOINT ["/app/staging.entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/app/entrypoint.sh"] \ No newline at end of file diff --git a/node/amuman_node/main.py b/node/amuman_node/main.py index 636f507..3d264ff 100644 --- a/node/amuman_node/main.py +++ b/node/amuman_node/main.py @@ -39,8 +39,10 @@ def __init__(self) -> None: self.manager_domain: str = os.getenv("MANAGER_DOMAIN", "localhost:8000") self.node_id: int = int(os.getenv("NODE_ID", 0)) self.node_name: str = os.getenv("NODE_NAME", str(uuid.uuid1())) + self.node_user: str = os.getenv("NODE_USER", "admin") + self.node_password: str = os.getenv("NODE_PASSWORD", "admin") log.debug( - f"Manager URL: '{self.manager_domain}', Node ID: {self.node_id}, Node Name: '{self.node_name}'" + f"Manager domain: '{self.manager_domain}', Node ID: {self.node_id}, Node Name: '{self.node_name}'" ) self.reconnect_attempts: int = 10 self.reconnect_delay: int = 10 @@ -66,12 +68,14 @@ async def start(self) -> None: await asyncio.sleep(self.sleep_time) def authenticate(self) -> bool: + print(f"https://{self.manager_domain}/api/token/") + print(self.node_user, self.node_password) try: response = requests.post( - f"http://{self.manager_domain}/api/token/", + f"https://{self.manager_domain}/api/token/", json={ - "username": os.getenv("NODE_USER", "admin"), - "password": os.getenv("NODE_PASSWORD", "admin"), + "username": self.node_user, + "password": self.node_password, }, ) log.debug( diff --git a/node/staging.entrypoint.sh b/node/entrypoint.sh similarity index 100% rename from node/staging.entrypoint.sh rename to node/entrypoint.sh diff --git a/node/justfile b/node/justfile index 0e9b5ff..6186755 100644 --- a/node/justfile +++ b/node/justfile @@ -13,15 +13,3 @@ dev cmd="bash": -e NODE_NAME=test_node \ --env-file ../.env \ amuman-node-dev {{cmd}} - -staging: - podman network create --ignore amuman-staging - podman build . -t amuman-node-staging - podman run --rm -it --replace --tz local --pull newer \ - --name amuman-node-staging \ - --network amuman-dev \ - -v ./..:/app \ - -v ./../mock_nas:/mnt/smb \ - -w /app/node \ - --device=nvidia.com/gpu=all \ - amuman-node-staging diff --git a/proxy/nginx.conf b/proxy/nginx.conf index 966ad95..ac8ee63 100644 --- a/proxy/nginx.conf +++ b/proxy/nginx.conf @@ -1,21 +1,19 @@ server { client_max_body_size 1G; - listen 80; - server_name localhost; location /api/ { - proxy_pass http://amuman-manager-staging:8000; + proxy_pass http://amuman-manager:8000; } location /admin/ { - proxy_pass http://amuman-manager-staging:8000; + proxy_pass http://amuman-manager:8000; } location /static/ { - proxy_pass http://amuman-manager-staging:8000; + proxy_pass http://amuman-manager:8000; } location / { - proxy_pass http://amuman-frontend-staging:3000/; + proxy_pass http://amuman-frontend:3000/; } } \ No newline at end of file