-
Notifications
You must be signed in to change notification settings - Fork 7
feat: high level wrapper around Docker API #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8d44b25
feat: high level wrapper around Docker API
oleksandr-nc 36b9f41
refactor: created helper _install_frp_certificates function
oleksandr-nc 77fc464
fix: CUDA deploy
oleksandr-nc fc658f7
refactor: new _install_system_certificates sub-function
oleksandr-nc 49e2380
final small refactor
oleksandr-nc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| FROM haproxy:3.1.2-alpine3.21 | ||
|
|
||
| USER root | ||
|
|
||
| # Bind addresses for 2 frontends (HTTP + HTTPS for exapps) and FRP Server. | ||
| # If /certs/cert.pem does not exist, EXAPPS HTTPS frontend are disabled automatically. | ||
| ENV HP_EXAPPS_ADDRESS="0.0.0.0:8780" \ | ||
| HP_EXAPPS_HTTPS_ADDRESS="0.0.0.0:8781" \ | ||
| HP_FRP_ADDRESS="0.0.0.0:8782" \ | ||
| HP_FRP_DISABLE_TLS="false" \ | ||
| HP_TIMEOUT_CONNECT="30s" \ | ||
| HP_TIMEOUT_CLIENT="30s" \ | ||
| HP_TIMEOUT_SERVER="1800s" \ | ||
| NC_INSTANCE_URL="" \ | ||
| HP_LOG_LEVEL="warning" | ||
|
|
||
| RUN set -ex; \ | ||
| apk add --no-cache \ | ||
| git \ | ||
| ca-certificates \ | ||
| tzdata \ | ||
| bash \ | ||
| curl \ | ||
| openssl \ | ||
| bind-tools \ | ||
| nano \ | ||
| vim \ | ||
| envsubst \ | ||
| frp \ | ||
| python3 \ | ||
| py3-pip \ | ||
| py3-aiohttp \ | ||
| wget \ | ||
| tar \ | ||
| netcat-openbsd; \ | ||
| chmod -R 777 /tmp; | ||
|
|
||
| # Main haproxy config template | ||
| COPY --chmod=664 ./development/debugging/haproxy.cfg /haproxy.cfg | ||
|
|
||
| # SPOE config | ||
| COPY --chmod=664 spoe-agent.conf /etc/haproxy/spoe-agent.conf | ||
|
|
||
| ENTRYPOINT ["haproxy", "-f", "/haproxy.cfg", "-W", "-db"] | ||
|
|
||
| LABEL com.centurylinklabs.watchtower.enable="false" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| serverAddr = "127.0.0.1" # Replace with your HP_FRP_ADDRESS host | ||
| serverPort = 8782 # Default port for FRP or the port your reverse proxy listens on | ||
| loginFailExit = false # If the FRP (HaRP) server is unavailable, continue trying to log in. | ||
|
|
||
| metadatas.token = "some_very_secure_password" | ||
|
|
||
| log.level = "info" | ||
|
|
||
| [[proxies]] | ||
| remotePort = 24000 # we set it to 24000 as it is the basic Docker Engine | ||
| name = "bundled-deploy-daemon" # Unique name for each Docker Engine | ||
| type = "tcp" | ||
| [proxies.plugin] | ||
| type = "unix_domain_socket" | ||
| unixPath = "/var/run/docker.sock" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| bindAddr = "127.0.0.1" | ||
| bindPort = 8782 | ||
|
|
||
| transport.tls.force = false | ||
|
|
||
| log.level = "info" | ||
|
|
||
| maxPortsPerClient = 1 | ||
| allowPorts = [ | ||
| { start = 23000, end = 23999 }, | ||
| { start = 24000, end = 24099 } | ||
| ] | ||
|
|
||
| [[httpPlugins]] | ||
| addr = "127.0.0.1:8200" | ||
| path = "/frp_handler" | ||
| ops = ["Login"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| global | ||
| log stdout local0 info | ||
| maxconn 8192 | ||
| ca-base /etc/ssl/certs | ||
|
|
||
| defaults | ||
| log global | ||
| option httplog | ||
| option dontlognull | ||
| timeout connect 30s | ||
| timeout client 30s | ||
| timeout server 1800s | ||
|
|
||
|
|
||
| ############################################################################### | ||
| # FRONTEND: ex_apps (HTTP) | ||
| ############################################################################### | ||
| frontend ex_apps | ||
| mode http | ||
| bind 0.0.0.0:8780 | ||
|
|
||
| filter spoe engine exapps-spoe config /etc/haproxy/spoe-agent.conf | ||
| http-request silent-drop if { var(txn.exapps.bad_request) -m int eq 1 } | ||
| http-request return status 401 content-type text/plain string "401 Unauthorized" if { var(txn.exapps.unauthorized) -m int eq 1 } | ||
| http-request return status 403 content-type text/plain string "403 Forbidden" if { var(txn.exapps.forbidden) -m int eq 1 } | ||
| http-request return status 404 content-type text/plain string "404 Not Found" if { var(txn.exapps.not_found) -m int eq 1 } | ||
| use_backend %[var(txn.exapps.backend)] | ||
|
|
||
| ############################################################################### | ||
| # BACKENDS: ex_apps & ex_apps_backend_w_bruteforce | ||
| ############################################################################### | ||
| backend ex_apps_backend | ||
| mode http | ||
| server frp_server 0.0.0.0 | ||
| http-request set-path %[var(txn.exapps.target_path)] | ||
| http-request set-dst var(txn.exapps.target_ip) | ||
| http-request set-dst-port var(txn.exapps.target_port) | ||
| http-request set-header EX-APP-ID %[var(txn.exapps.exapp_id)] | ||
| http-request set-header EX-APP-VERSION %[var(txn.exapps.exapp_version)] | ||
| http-request set-header AUTHORIZATION-APP-API %[var(txn.exapps.exapp_token)] | ||
| http-request set-header AA-VERSION "32" # TO-DO: temporary, remove it after we update all ExApps. | ||
|
|
||
| backend ex_apps_backend_w_bruteforce | ||
| mode http | ||
| server frp_server 0.0.0.0 | ||
| http-request set-path %[var(txn.exapps.target_path)] | ||
| http-request set-dst var(txn.exapps.target_ip) | ||
| http-request set-dst-port var(txn.exapps.target_port) | ||
| http-request set-header EX-APP-ID %[var(txn.exapps.exapp_id)] | ||
| http-request set-header EX-APP-VERSION %[var(txn.exapps.exapp_version)] | ||
| http-request set-header AUTHORIZATION-APP-API %[var(txn.exapps.exapp_token)] | ||
| http-request set-header AA-VERSION "32" # TO-DO: temporary, remove it after we update all ExApps. | ||
| filter spoe engine exapps-bruteforce-protection-spoe config /etc/haproxy/spoe-agent.conf | ||
|
|
||
| ############################################################################### | ||
| # BACKEND: nextcloud_control (HTTP) | ||
| ############################################################################### | ||
| backend nextcloud_control_backend | ||
| mode http | ||
| server nextcloud_control 127.0.0.1:8200 | ||
| http-request set-path %[var(txn.exapps.target_path)] | ||
|
|
||
| ############################################################################### | ||
| # BACKEND: docker_engine (HTTP) | ||
| ############################################################################### | ||
| backend docker_engine_backend | ||
| mode http | ||
| server frp_server 127.0.0.1 | ||
| http-request set-dst-port var(txn.exapps.target_port) | ||
| http-request set-path %[var(txn.exapps.target_path)] | ||
|
|
||
| # docker system _ping | ||
| http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/_ping$ } METH_GET | ||
| # docker inspect image | ||
| http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/images/.*/json } METH_GET | ||
| # container inspect: GET containers/%s/json | ||
| http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/nc_app_[a-zA-Z0-9_.-]+/json } METH_GET | ||
| # container inspect: GET containers/%s/logs | ||
| http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/nc_app_[a-zA-Z0-9_.-]+/logs } METH_GET | ||
|
|
||
| # image pull: POST images/create?fromImage=%s | ||
| http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/images/create } METH_POST | ||
| http-request deny | ||
|
|
||
|
|
||
| backend agents | ||
| mode tcp | ||
| timeout connect 5s | ||
| timeout server 3m | ||
| option spop-check | ||
| server agent1 127.0.0.1:9600 check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/sh | ||
| # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| # This file can be used for development for the "manual install" deployment type when FRP is disabled. | ||
| # For Julius Docker-Dev, you need to additionally edit the `data/nginx/vhost.d/nextcloud.local_location` file, | ||
| # changing `appapi-harp` to `172.17.0.1` and restart the "proxy" container. | ||
|
|
||
| docker container remove --force appapi-harp | ||
|
|
||
| docker build -f development/debugging/Dockerfile -t nextcloud-appapi-harp:debug . | ||
|
|
||
| docker run \ | ||
| --name appapi-harp -h appapi-harp \ | ||
| --restart unless-stopped \ | ||
| --network=host \ | ||
| -d nextcloud-appapi-harp:debug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.