From ee00c687f00d56950924cc0d69d031a93010c308 Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Fri, 24 Jan 2025 10:38:10 +0300 Subject: [PATCH 01/10] [devcontainer] add dev files --- .devcontainer/.mise.toml | 2 + .devcontainer/Dockerfile | 70 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 40 +++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .devcontainer/.mise.toml create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/.mise.toml b/.devcontainer/.mise.toml new file mode 100644 index 0000000..eaf6f4a --- /dev/null +++ b/.devcontainer/.mise.toml @@ -0,0 +1,2 @@ +[tools] +python = '3.10' # must be after pipenv so the pipenv bin is first in PATH \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..ee6c3d2 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,70 @@ +FROM ubuntu:24.10 AS build-env + +USER root + +RUN apt-get update && apt-get install -y yarn +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ +< /dev/null + + echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=amd64] https://mise.jdx.dev/deb stable main" \ + | tee /etc/apt/sources.list.d/mise.list + + apt-get update + apt-get install -y mise +EOR + +FROM build-env AS dev-env + +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ +< /etc/sudoers.d/$USERNAME + chmod 0440 /etc/sudoers.d/$USERNAME +EOR + +USER $USERNAME + +RUN --mount=type=cache,target=/$USERNAME/.cache/mise,sharing=locked \ + --mount=type=bind,source=.mise.toml,target=.mise.toml,readonly \ +< Date: Fri, 24 Jan 2025 17:03:56 +0300 Subject: [PATCH 02/10] [devcontainer] add correct yarn install --- .devcontainer/Dockerfile | 5 +++-- .devcontainer/devcontainer.json | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ee6c3d2..adbab47 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,7 +2,6 @@ FROM ubuntu:24.10 AS build-env USER root -RUN apt-get update && apt-get install -y yarn RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ < Date: Mon, 27 Jan 2025 13:25:25 +0300 Subject: [PATCH 03/10] [hardpy] add setting files --- .devcontainer/couchdb.ini | 109 +++++++++++++++++++++++++ .devcontainer/devcontainer.json | 9 +- .devcontainer/local.ini | 2 + .devcontainer/Dockerfile => Dockerfile | 20 +++++ 4 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 .devcontainer/couchdb.ini create mode 100644 .devcontainer/local.ini rename .devcontainer/Dockerfile => Dockerfile (79%) diff --git a/.devcontainer/couchdb.ini b/.devcontainer/couchdb.ini new file mode 100644 index 0000000..4eb634f --- /dev/null +++ b/.devcontainer/couchdb.ini @@ -0,0 +1,109 @@ +; CouchDB Configuration Settings + +; Custom settings should be made in this file. They will override settings +; in default.ini, but unlike changes made to default.ini, this file won't be +; overwritten on server upgrade. + +[couchdb] +;max_document_size = 4294967296 ; bytes +;os_process_timeout = 5000 + +[couch_peruser] +; If enabled, couch_peruser ensures that a private per-user database +; exists for each document in _users. These databases are writable only +; by the corresponding user. Databases are in the following form: +; userdb-{hex encoded username} +;enable = true + +; If set to true and a user is deleted, the respective database gets +; deleted as well. +;delete_dbs = true + +; Set a default q value for peruser-created databases that is different from +; cluster / q +;q = 1 + +[chttpd] +;port = 5984 +;bind_address = localhost + +; Options for the MochiWeb HTTP server. +;server_options = [{backlog, 128}, {acceptor_pool_size, 16}] + +; For more socket options, consult Erlang's module 'inet' man page. +;socket_options = [{sndbuf, 262144}, {nodelay, true}] + +enable_cors=true + +[httpd] +; NOTE that this only configures the "backend" node-local port, not the +; "frontend" clustered port. You probably don't want to change anything in +; this section. +; Uncomment next line to trigger basic-auth popup on unauthorized requests. +;WWW-Authenticate = Basic realm="administrator" + +; Uncomment next line to set the configuration modification whitelist. Only +; whitelisted values may be changed via the /_config URLs. To allow the admin +; to change this value over HTTP, remember to include {httpd,config_whitelist} +; itself. Excluding it from the list would require editing this file to update +; the whitelist. +;config_whitelist = [{httpd,config_whitelist}, {log,level}, {etc,etc}] + +[cors] +origins = * +methods = GET, PUT, POST, HEAD, DELETE +credentials = true +headers = accept, authorization, content-type, origin, referer, x-csrf-token + + +[ssl] +;enable = true +;cert_file = /full/path/to/server_cert.pem +;key_file = /full/path/to/server_key.pem +;password = somepassword + +; set to true to validate peer certificates +;verify_ssl_certificates = false + +; Set to true to fail if the client does not send a certificate. Only used if verify_ssl_certificates is true. +;fail_if_no_peer_cert = false + +; Path to file containing PEM encoded CA certificates (trusted +; certificates used for verifying a peer certificate). May be omitted if +; you do not want to verify the peer. +;cacert_file = /full/path/to/cacertf + +; The verification fun (optional) if not specified, the default +; verification fun will be used. +;verify_fun = {Module, VerifyFun} + +; maximum peer certificate depth +;ssl_certificate_max_depth = 1 + +; Reject renegotiations that do not live up to RFC 5746. +;secure_renegotiate = true + +; The cipher suites that should be supported. +; Can be specified in erlang format "{ecdhe_ecdsa,aes_128_cbc,sha256}" +; or in OpenSSL format "ECDHE-ECDSA-AES128-SHA256". +;ciphers = ["ECDHE-ECDSA-AES128-SHA256", "ECDHE-ECDSA-AES128-SHA"] + +; The SSL/TLS versions to support +;tls_versions = [tlsv1, 'tlsv1.1', 'tlsv1.2'] + +; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to +; the Virtual Host will be redirected to the path. In the example below all requests +; to http://example.com/ are redirected to /database. +; If you run CouchDB on a specific port, include the port number in the vhost: +; example.com:5984 = /database +[vhosts] +;example.com = /database/ + +; To create an admin account uncomment the '[admins]' section below and add a +; line in the format 'username = password'. When you next start CouchDB, it +; will change the password to a hash (so that your passwords don't linger +; around in plain-text files). You can add more admin accounts with more +; 'username = password' lines. Don't forget to restart CouchDB after +; changing this. +[admins] +;admin = mysecretpassword diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d883226..99119cc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "Ubuntu", "build": { - "dockerfile": "Dockerfile" + "dockerfile": "../Dockerfile" }, "forwardPorts": [ "8000:8000", // API @@ -9,7 +9,7 @@ ], // debuild puts its artifact to project's parent directory "postCreateCommand": "sudo chown $(whoami):$(whoami) /workspaces", - "postAttachCommand": "mise exec -- python3 -m venv .venv && .venv/bin/python3 -m pip install -e .[dev] && cd hardpy/hardpy_panel/frontend && corepack yarn install", + "postAttachCommand": "mise exec -- python3 -m venv .venv && .venv/bin/python3 -m pip install -e .[dev] && cd hardpy/hardpy_panel/frontend && corepack yarn install && service couchdb start", "customizations": { "vscode": { "extensions": [ @@ -22,7 +22,10 @@ "ms-python.debugpy", "charliermarsh.ruff", "mhutchie.git-graph", - "hverlin.mise-vscode" + "hverlin.mise-vscode", + "njpwerner.autodocstring", + "bungcip.better-toml", + "esbenp.prettier-vscode" ], "settings": { "terminal.integrated.detectLocale": "off" diff --git a/.devcontainer/local.ini b/.devcontainer/local.ini new file mode 100644 index 0000000..f34cfe5 --- /dev/null +++ b/.devcontainer/local.ini @@ -0,0 +1,2 @@ +[couchdb] +database_dir = /dev/shm/couchdb \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/Dockerfile similarity index 79% rename from .devcontainer/Dockerfile rename to Dockerfile index adbab47..8019317 100644 --- a/.devcontainer/Dockerfile +++ b/Dockerfile @@ -69,3 +69,23 @@ RUN --mount=type=cache,target=/$USERNAME/.cache/mise,sharing=locked \ mise trust --yes .mise.toml mise install EOR + +COPY pyproject.toml /workspaces/pyproject.toml +RUN python3 -m venv /workspaces/.venv && \ + /workspaces/.venv/bin/python3 -m pip install --upgrade pip && \ + /workspaces/.venv/bin/python3 -m pip install -e /workspaces[dev] + + +FROM couchdb + +COPY .devcontainers/local.ini /opt/couchdb/etc/local.ini + +ENV COUCHDB_USER=dev +ENV COUCHDB_PASSWORD=dev + +RUN echo "[httpd]\nport = 5984\n" >> /opt/couchdb/etc/local.ini + +EXPOSE 5984 + +CMD ["service", "couchdb", "start"] + From 99e897833ce3d8aee3ffcd0c6ebdb620375b59dc Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Mon, 27 Jan 2025 16:46:43 +0300 Subject: [PATCH 04/10] [hardpy] correct launching --- .devcontainer/devcontainer.json | 5 +++-- .mise.toml | 2 ++ .vscode/launch.json | 16 ++++++++++++++++ Dockerfile | 23 ++++++++++++----------- 4 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 .mise.toml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 99119cc..3d93a32 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,11 +5,12 @@ }, "forwardPorts": [ "8000:8000", // API - "3000:3000" // App + "3000:3000", // App + "5984:5984" ], // debuild puts its artifact to project's parent directory "postCreateCommand": "sudo chown $(whoami):$(whoami) /workspaces", - "postAttachCommand": "mise exec -- python3 -m venv .venv && .venv/bin/python3 -m pip install -e .[dev] && cd hardpy/hardpy_panel/frontend && corepack yarn install && service couchdb start", + "postAttachCommand": "python3 -m venv .venv && .venv/bin/python3 -m pip install -e .[dev] && cd hardpy/hardpy_panel/frontend && corepack yarn install", "customizations": { "vscode": { "extensions": [ diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..eaf6f4a --- /dev/null +++ b/.mise.toml @@ -0,0 +1,2 @@ +[tools] +python = '3.10' # must be after pipenv so the pipenv bin is first in PATH \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index c07db47..6b9179b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -136,6 +136,22 @@ "webRoot": "${workspaceFolder}/hardpy/hardpy_panel/frontend", "sourceMaps": true, "timeout": 30000 + }, + { + "name": "Python: Example Dialog box (DevContainer)", + "type": "debugpy", + "request": "launch", + "module": "hardpy.cli.cli", + "console": "integratedTerminal", + "args": [ + "run", + "examples/dialog_box" + ], + "python": "/usr/local/bin/python3", // Adjust this path if necessary + "cwd": "/workspace", // Adjust this to your workspace directory in the container + "env": { + "PYTHONPATH": "/workspace" // Adjust if your Python path is different + } } ] } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8019317..b2a5170 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ python3-pip \ node-corepack \ python3-venv \ + sudo \ gpg \ wget \ curl \ @@ -70,22 +71,22 @@ RUN --mount=type=cache,target=/$USERNAME/.cache/mise,sharing=locked \ mise install EOR -COPY pyproject.toml /workspaces/pyproject.toml -RUN python3 -m venv /workspaces/.venv && \ - /workspaces/.venv/bin/python3 -m pip install --upgrade pip && \ - /workspaces/.venv/bin/python3 -m pip install -e /workspaces[dev] +# COPY pyproject.toml /workspaces/pyproject.toml +# RUN python3 -m venv /workspaces/.venv && \ +# /workspaces/.venv/bin/python3 -m pip install --upgrade pip && \ +# /workspaces/.venv/bin/python3 -m pip install -e /workspaces[dev] -FROM couchdb +# FROM couchdb -COPY .devcontainers/local.ini /opt/couchdb/etc/local.ini +# COPY .devcontainer/local.ini /opt/couchdb/etc/local.ini -ENV COUCHDB_USER=dev -ENV COUCHDB_PASSWORD=dev +# ENV COUCHDB_USER=dev +# ENV COUCHDB_PASSWORD=dev -RUN echo "[httpd]\nport = 5984\n" >> /opt/couchdb/etc/local.ini +# RUN echo "[httpd]\nport = 5984\n" >> /opt/couchdb/etc/local.ini -EXPOSE 5984 +# EXPOSE 5984 -CMD ["service", "couchdb", "start"] +# CMD ["service", "couchdb", "start"] From de0f8a55da8bad4ef703ddd940791387f9d36ff6 Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Wed, 29 Jan 2025 14:16:18 +0300 Subject: [PATCH 05/10] [vscode] add debug --- .vscode/launch.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index c2dd9d5..56a2ca4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -149,7 +149,8 @@ "python": "/usr/local/bin/python3", // Adjust this path if necessary "cwd": "/workspace", // Adjust this to your workspace directory in the container "env": { - "PYTHONPATH": "/workspace" // Adjust if your Python path is different + "PYTHONPATH": "/workspace", // Adjust if your Python path is different + "DEBUG_FRONTEND": "1", } } ] From 1fe53cbb9e329f4af54a6c9bf233f8d013b77235 Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Fri, 31 Jan 2025 10:44:23 +0300 Subject: [PATCH 06/10] [devcontainer] correct base files --- .devcontainer/devcontainer.json | 3 +-- Dockerfile | 40 --------------------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3d93a32..1ee1b3c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,7 @@ ], // debuild puts its artifact to project's parent directory "postCreateCommand": "sudo chown $(whoami):$(whoami) /workspaces", - "postAttachCommand": "python3 -m venv .venv && .venv/bin/python3 -m pip install -e .[dev] && cd hardpy/hardpy_panel/frontend && corepack yarn install", + "postAttachCommand": "pip3 install -e .[dev] --break-system-packages && cd hardpy/hardpy_panel/frontend && corepack yarn install", "customizations": { "vscode": { "extensions": [ @@ -23,7 +23,6 @@ "ms-python.debugpy", "charliermarsh.ruff", "mhutchie.git-graph", - "hverlin.mise-vscode", "njpwerner.autodocstring", "bungcip.better-toml", "esbenp.prettier-vscode" diff --git a/Dockerfile b/Dockerfile index b2a5170..0e4216a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,20 +29,6 @@ EOR RUN apt-get update && corepack enable && yarn init -2 -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ - --mount=type=cache,target=/var/lib/apt,sharing=locked \ -< /dev/null - - echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=amd64] https://mise.jdx.dev/deb stable main" \ - | tee /etc/apt/sources.list.d/mise.list - - apt-get update - apt-get install -y mise -EOR FROM build-env AS dev-env @@ -62,31 +48,5 @@ RUN <> /opt/couchdb/etc/local.ini - -# EXPOSE 5984 -# CMD ["service", "couchdb", "start"] From f719e15f54d702a252a4ed7cd625327b715d5849 Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Fri, 31 Jan 2025 16:27:43 +0300 Subject: [PATCH 07/10] [hardpy] change config files for devcontainer --- .devcontainer/.mise.toml | 2 -- .devcontainer/devcontainer.json | 62 ++++++++++++++++----------------- .vscode/launch.json | 10 ++++-- Dockerfile | 34 +++++++++++------- scripts/recompile_front.sh | 2 +- 5 files changed, 60 insertions(+), 50 deletions(-) delete mode 100644 .devcontainer/.mise.toml diff --git a/.devcontainer/.mise.toml b/.devcontainer/.mise.toml deleted file mode 100644 index eaf6f4a..0000000 --- a/.devcontainer/.mise.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tools] -python = '3.10' # must be after pipenv so the pipenv bin is first in PATH \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1ee1b3c..46df743 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,43 +1,41 @@ { "name": "Ubuntu", "build": { - "dockerfile": "../Dockerfile" + "dockerfile": "../Dockerfile" }, "forwardPorts": [ - "8000:8000", // API - "3000:3000", // App - "5984:5984" + 8000 // API ], - // debuild puts its artifact to project's parent directory - "postCreateCommand": "sudo chown $(whoami):$(whoami) /workspaces", - "postAttachCommand": "pip3 install -e .[dev] --break-system-packages && cd hardpy/hardpy_panel/frontend && corepack yarn install", + + "postCreateCommand": "sudo chown $(whoami):$(whoami) /workspaces && sudo apt update && sudo apt install -y curl apt-transport-https gnupg && curl https://couchdb.apache.org/repo/keys.asc | gpg --dearmor | sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg >/dev/null 2>&1 && . /etc/os-release && echo \"deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ ${VERSION_CODENAME} main\" | sudo tee /etc/apt/sources.list.d/couchdb.list >/dev/null && sudo apt update && sudo apt install -y couchdb", + "postAttachCommand": "pip3 install --upgrade pip && pip3 install -e .[dev] --break-system-packages && cd hardpy/hardpy_panel/frontend && corepack yarn install", "customizations": { - "vscode": { - "extensions": [ - "rvest.vs-code-prettier-eslint", - "dbaeumer.vscode-eslint", - "codeandstuff.package-json-upgrade", - "tamasfe.even-better-toml", - "nefrob.vscode-just-syntax", - "ms-python.python", - "ms-python.debugpy", - "charliermarsh.ruff", - "mhutchie.git-graph", - "njpwerner.autodocstring", - "bungcip.better-toml", - "esbenp.prettier-vscode" - ], - "settings": { - "terminal.integrated.detectLocale": "off" - } + "vscode": { + "extensions": [ + "rvest.vs-code-prettier-eslint", + "dbaeumer.vscode-eslint", + "codeandstuff.package-json-upgrade", + "tamasfe.even-better-toml", + "nefrob.vscode-just-syntax", + "ms-python.python", + "ms-python.debugpy", + "charliermarsh.ruff", + "mhutchie.git-graph", + "njpwerner.autodocstring", + "bungcip.better-toml", + "esbenp.prettier-vscode" + ], + "settings": { + "terminal.integrated.detectLocale": "off" } + } }, "runArgs": [ - "-e", - "DISPLAY=${localEnv:DISPLAY}", // Wayland socket endpoint - "-v", - "/tmp/.X11-unix:/tmp/.X11-unix", // X11 socket - "--hostname", - "hardpy-devcontainer" + "-e", + "DISPLAY=${localEnv:DISPLAY}", // Wayland socket endpoint + "-v", + "/tmp/.X11-unix:/tmp/.X11-unix", // X11 socket + "--hostname", + "hardpy-devcontainer" ] -} +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 56a2ca4..e5eab98 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -77,7 +77,10 @@ "args": [ "run", "examples/minute_parity" - ] + ], + "env": { + "DEBUG_FRONTEND": "1", + } }, { "name": "Python: Example Dialog box", @@ -88,7 +91,10 @@ "args": [ "run", "examples/dialog_box" - ] + ], + "env": { + "DEBUG_FRONTEND": "1", + } }, { "name": "Python: Example Attempts", diff --git a/Dockerfile b/Dockerfile index 0e4216a..3ff5d32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,24 @@ -FROM ubuntu:24.10 AS build-env +FROM ubuntu:22.04 AS build-env USER root RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ < /etc/sudoers.d/$USERNAME + echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \ chmod 0440 /etc/sudoers.d/$USERNAME EOR - - - diff --git a/scripts/recompile_front.sh b/scripts/recompile_front.sh index 4f2bf1d..a3bdb4b 100755 --- a/scripts/recompile_front.sh +++ b/scripts/recompile_front.sh @@ -16,4 +16,4 @@ rm -rf __pycache__ # Build pip install -r requirements.txt -python -m build +python3 -m build From 0eabbe5d727fe86de1ab7275dac1928a4ecc6aee Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Tue, 4 Feb 2025 11:58:24 +0300 Subject: [PATCH 08/10] [hardpy] add changes for devcontainer --- .devcontainer/couchdb.ini | 2 +- .devcontainer/devcontainer.json | 7 ++++--- .devcontainer/local.ini | 2 -- .devcontainer/postattach.sh | 8 ++++++++ .devcontainer/postcreate.sh | 31 +++++++++++++++++++++++++++++++ .mise.toml | 2 -- .vscode/launch.json | 27 ++------------------------- Dockerfile | 1 + 8 files changed, 47 insertions(+), 33 deletions(-) delete mode 100644 .devcontainer/local.ini create mode 100644 .devcontainer/postattach.sh create mode 100644 .devcontainer/postcreate.sh delete mode 100644 .mise.toml diff --git a/.devcontainer/couchdb.ini b/.devcontainer/couchdb.ini index 4eb634f..f3d8ffa 100644 --- a/.devcontainer/couchdb.ini +++ b/.devcontainer/couchdb.ini @@ -106,4 +106,4 @@ headers = accept, authorization, content-type, origin, referer, x-csrf-token ; 'username = password' lines. Don't forget to restart CouchDB after ; changing this. [admins] -;admin = mysecretpassword +dev = dev diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 46df743..e7dd138 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,13 +2,14 @@ "name": "Ubuntu", "build": { "dockerfile": "../Dockerfile" + // ./database/couchdb.ini:/opt/couchdb/etc/local.ini }, "forwardPorts": [ - 8000 // API + 5984 // API ], - "postCreateCommand": "sudo chown $(whoami):$(whoami) /workspaces && sudo apt update && sudo apt install -y curl apt-transport-https gnupg && curl https://couchdb.apache.org/repo/keys.asc | gpg --dearmor | sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg >/dev/null 2>&1 && . /etc/os-release && echo \"deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ ${VERSION_CODENAME} main\" | sudo tee /etc/apt/sources.list.d/couchdb.list >/dev/null && sudo apt update && sudo apt install -y couchdb", - "postAttachCommand": "pip3 install --upgrade pip && pip3 install -e .[dev] --break-system-packages && cd hardpy/hardpy_panel/frontend && corepack yarn install", + "postCreateCommand": "bash ./.devcontainer/postcreate.sh", + "postAttachCommand": "bash ./.devcontainer/postattach.sh", "customizations": { "vscode": { "extensions": [ diff --git a/.devcontainer/local.ini b/.devcontainer/local.ini deleted file mode 100644 index f34cfe5..0000000 --- a/.devcontainer/local.ini +++ /dev/null @@ -1,2 +0,0 @@ -[couchdb] -database_dir = /dev/shm/couchdb \ No newline at end of file diff --git a/.devcontainer/postattach.sh b/.devcontainer/postattach.sh new file mode 100644 index 0000000..a58a249 --- /dev/null +++ b/.devcontainer/postattach.sh @@ -0,0 +1,8 @@ +pip3 install --upgrade pip + +pip3 install -e .[dev] +cd hardpy/hardpy_panel/frontend +corepack enable +corepack prepare yarn@4.0.1 --activate +yarn set version 4.0.1 +corepack yarn install \ No newline at end of file diff --git a/.devcontainer/postcreate.sh b/.devcontainer/postcreate.sh new file mode 100644 index 0000000..62cb656 --- /dev/null +++ b/.devcontainer/postcreate.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +sudo chown $(whoami):$(whoami) /workspaces + +sudo apt update +sudo apt install -y \ + curl \ + apt-transport-https \ + gnupg + +curl https://couchdb.apache.org/repo/keys.asc | \ + gpg --dearmor | \ + sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg > /dev/null 2>&1 + +. /etc/os-release + +echo "deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ ${VERSION_CODENAME} main" \ + | sudo tee /etc/apt/sources.list.d/couchdb.list > /dev/null + +sudo apt update + +sudo apt-get install -y couchdb + +sudo cp .devcontainer/couchdb.ini /opt/couchdb/etc/local.ini + +sudo service couchdb start + +sudo service couchdb stop + + + diff --git a/.mise.toml b/.mise.toml deleted file mode 100644 index eaf6f4a..0000000 --- a/.mise.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tools] -python = '3.10' # must be after pipenv so the pipenv bin is first in PATH \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index e5eab98..2226e0f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -77,10 +77,7 @@ "args": [ "run", "examples/minute_parity" - ], - "env": { - "DEBUG_FRONTEND": "1", - } + ] }, { "name": "Python: Example Dialog box", @@ -91,10 +88,7 @@ "args": [ "run", "examples/dialog_box" - ], - "env": { - "DEBUG_FRONTEND": "1", - } + ] }, { "name": "Python: Example Attempts", @@ -141,23 +135,6 @@ "webRoot": "${workspaceFolder}/hardpy/hardpy_panel/frontend", "sourceMaps": true, "timeout": 30000 - }, - { - "name": "Python: Example Dialog box (DevContainer)", - "type": "debugpy", - "request": "launch", - "module": "hardpy.cli.cli", - "console": "integratedTerminal", - "args": [ - "run", - "examples/dialog_box" - ], - "python": "/usr/local/bin/python3", // Adjust this path if necessary - "cwd": "/workspace", // Adjust this to your workspace directory in the container - "env": { - "PYTHONPATH": "/workspace", // Adjust if your Python path is different - "DEBUG_FRONTEND": "1", - } } ] } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3ff5d32..fb35039 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ gpg \ wget \ git \ + net-tools \ && rm -rf /var/lib/apt/lists/* EOR From dcacbd80d8fd7b2e1b74ab73567a2bd9f5a5909f Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Tue, 4 Feb 2025 14:52:01 +0300 Subject: [PATCH 09/10] [docs] add description --- docs/about/development.md | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/docs/about/development.md b/docs/about/development.md index 547b680..f0e8f1f 100644 --- a/docs/about/development.md +++ b/docs/about/development.md @@ -191,6 +191,46 @@ Addresses: - HardPy panel: http://localhost:8000/ - CouchDB: http://localhost:5984/_utils/ +## Dev Container + +Ensure that Docker is running and functioning correctly before starting the container build. + +### Step 1: Build the Container + +1. Open the project in Visual Studio Code (VSCode). +2. Press `Ctrl+Shift+P` to open the command palette. +3. Type and select the command: **Dev Containers: Rebuild Container**. +4. Wait for the container build process to complete. + +### Step 2: Configure CouchDB + +During the container build, CouchDB will be installed. You will be prompted with configuration questions: + +- You can respond arbitrarily to most questions (for example, by entering `1`). +- **Important**: For the question **"CouchDB interface bind address:"**, you must respond with `0.0.0.0`. + +### Step 3: Run the Project + +After successfully building the container, you can work with the project as usual. The following methods are available for running the project: + +#### Running via Script +- Use the `recompile_front.sh` script to rebuild and run the frontend. +- Execute the command in the terminal: + ```bash + hardpy run [example] + ``` + +#### Running via VSCode Configurations +- The following run configurations are available in VSCode: + - **Run Frontend** + - **Debug Frontend** + - Any of the examples with the addition of the argument: + ```json + "env": { + "DEBUG_FRONTEND": "1" + } + ``` + ## Documentation ### Server From 062f5acfc2c61795d6f2c27b511e805188955721 Mon Sep 17 00:00:00 2001 From: "m.antonovich" Date: Tue, 4 Feb 2025 15:00:17 +0300 Subject: [PATCH 10/10] [scripts] correct scripts --- .devcontainer/postattach.sh | 2 +- .devcontainer/postcreate.sh | 3 --- scripts/recompile_front.sh | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.devcontainer/postattach.sh b/.devcontainer/postattach.sh index a58a249..5532c65 100644 --- a/.devcontainer/postattach.sh +++ b/.devcontainer/postattach.sh @@ -5,4 +5,4 @@ cd hardpy/hardpy_panel/frontend corepack enable corepack prepare yarn@4.0.1 --activate yarn set version 4.0.1 -corepack yarn install \ No newline at end of file +corepack yarn install diff --git a/.devcontainer/postcreate.sh b/.devcontainer/postcreate.sh index 62cb656..e77ac6b 100644 --- a/.devcontainer/postcreate.sh +++ b/.devcontainer/postcreate.sh @@ -26,6 +26,3 @@ sudo cp .devcontainer/couchdb.ini /opt/couchdb/etc/local.ini sudo service couchdb start sudo service couchdb stop - - - diff --git a/scripts/recompile_front.sh b/scripts/recompile_front.sh index a3bdb4b..4f2bf1d 100755 --- a/scripts/recompile_front.sh +++ b/scripts/recompile_front.sh @@ -16,4 +16,4 @@ rm -rf __pycache__ # Build pip install -r requirements.txt -python3 -m build +python -m build