diff --git a/.build/dev/backend.Dockerfile b/.build/dev/backend.Dockerfile deleted file mode 100644 index 8350cd6..0000000 --- a/.build/dev/backend.Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM python:3.12-slim - -WORKDIR /var/www/html/ - -CMD pip install -r requirements.txt && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload diff --git a/.build/prod/README.md b/.build/prod/README.md index ec189bd..7839b0e 100644 --- a/.build/prod/README.md +++ b/.build/prod/README.md @@ -27,7 +27,7 @@ The portal is then available on `http://HOST:8000`. services: backend: hostname: backend - image: git.shihaam.dev/sarlink/radadmin/backed + image: git.shihaam.dev/sarlink/radadmin/backend env_file: - backend.env frontend: diff --git a/.build/prod/compose.yml b/.build/prod/compose.yml index 51d4460..bab2f07 100644 --- a/.build/prod/compose.yml +++ b/.build/prod/compose.yml @@ -6,10 +6,10 @@ services: args: VITE_API_TARGET: ${VITE_API_TARGET} hostname: frontend - image: git.shihaam.dev/sarlink/radadmin/backend + image: git.shihaam.dev/sarlink/radadmin/frontend backend: build: context: ../../ dockerfile: .build/prod/backend.Dockerfile hostname: backend - image: git.shihaam.dev/sarlink/radadmin/frontend + image: git.shihaam.dev/sarlink/radadmin/backend diff --git a/README.md b/README.md index 18d9721..7d6ef4f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,22 @@ frontend collects the key on a login screen and the backend validates it. ## Quick start +### With Docker (dev) + +Runs both services with hot-reload — the frontend on Vite, the backend on +`uvicorn --reload`, each with its source volume-mounted from the host. + +```bash +cp backend/.env.example backend/.env # edit DB credentials + API_KEY +docker compose up --build # frontend :5173, backend :8000 +``` + +The frontend proxies `/api/*` to the `backend` service over the compose +network, so log in at http://localhost:5173 with the `API_KEY` from +`backend/.env`. + +### Manual + **Backend** (see [`backend/README.md`](backend/README.md) for details): ```bash diff --git a/backend/compose.yml b/backend/compose.yml new file mode 100644 index 0000000..64fab66 --- /dev/null +++ b/backend/compose.yml @@ -0,0 +1,10 @@ +services: + backend: + build: + context: .build/dev + volumes: + - ./:/app + ports: + - 8000:8000 + env_file: + - .env diff --git a/backend/docs.txt.save b/backend/docs.txt.save deleted file mode 100644 index de2c833..0000000 --- a/backend/docs.txt.save +++ /dev/null @@ -1,71 +0,0 @@ - -adding a new device -example post /device/new -macaddress,group -removing an existing device - -listing vlans -GET /vlan/ -SELECT * FROM `radgroupreply` -this will return 3 duplicate "groupnames" with different attribute and vlaue -only need to return group name and value for Tunnel-Private-Group-Id - -adding new vlan -need to add 3 items with different attribute and value, -for example to add staff vlan with vlan ID 55 -api call should be like POST vlan/add and json data vlanid:55, alias staff - -'INSERT INTO `radgroupreply` (`groupname`, `attribute`, `op`, `value`) -VALUES ('staff', 'Tunnel-Type', '=', 'VLAN'); - -INSERT INTO `radgroupreply` (`groupname`, `attribute`, `op`, `value`) -VALUES ('staff', 'Tunnel-Medium-Type', '=', 'IEEE-802'); - -INSERT INTO `radgroupreply` (`groupname`, `attribute`, `op`, `value`) -VALUES ('staff', 'Tunnel-Private-Group-Id', '=', '55'); -' -deleting existing vlan -you get api call to delete vlan -DELETE vlan/55 -and the sqlcommands should you looking for Tunnel-Private-Group-Id=55 and then deleting all the maching group names - -edit existing vlan (alias) -post request, and allow to edit alias - -disallow to add duplicate vlans or alias - -listing existing devices -get /device/ -SELECT * FROM `radusergroup` -and then -SELECT * FROM `customers` -return mac address, groupname and status - -adding new device -this input feils are -' -POST /device/add with mac address and group and it involves few Commands -` -SELECT * FROM `radgroupreply` -# and see if the group in the device add command exists -# respond 4xx (whatever needed with reason group not found) -# else continue - -INSERT INTO `radcheck` (`username`, `attribute`, `op`, `value`) -VALUES ('14-99-3E-74-CB-7F', 'Cleartext-Password', ':=', '14-99-3E-74-CB-7F'); - -INSERT INTO `radusergroup` (`username`, `groupname`, `priority`) -VALUES ('14-99-3E-74-CB-7F', 'staff', '1'); - -INSERT INTO `customers` (`username`, `mac_address`, `status`, `created_at`) -VALUES ('14-99-3E-74-CB-7F', '14-99-3E-74-CB-7F', 'paid', now()); -` - -deleting existing deivce -edit existing device (input macaddress, edit groupname, edit status. do allow to edit just 1 feild) -use sesnible commands based on add devices - -i would also like a device alias, added to customers table like -"Customer name, device name, phone number" -these are to be ignored by radius server, but helpful for human review -and add input fields during adding device and also listing devices diff --git a/compose.yml b/compose.yml index 45dd926..706298f 100644 --- a/compose.yml +++ b/compose.yml @@ -1,8 +1,3 @@ -services: - frontend: - build: - context: .build/dev - volumes: - - ./:/var/www/html/ - ports: - - 5173:5173 +include: + - frontend/compose.yml + - backend/compose.yml diff --git a/.build/dev/frontend.Dockerfile b/frontend/.build/dev/Dockerfile similarity index 100% rename from .build/dev/frontend.Dockerfile rename to frontend/.build/dev/Dockerfile diff --git a/frontend/compose.yml b/frontend/compose.yml new file mode 100644 index 0000000..0b54c89 --- /dev/null +++ b/frontend/compose.yml @@ -0,0 +1,11 @@ +services: + frontend: + build: + context: .build/dev + dockerfile: frontend.Dockerfile + volumes: + - ./:/var/www/html/ + ports: + - 5173:5173 + env_file: + - .env