apx-dokploy 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- apx_dokploy-0.1.0/LICENSE +201 -0
- apx_dokploy-0.1.0/PKG-INFO +87 -0
- apx_dokploy-0.1.0/README.md +71 -0
- apx_dokploy-0.1.0/apx_dokploy/__init__.py +5 -0
- apx_dokploy-0.1.0/apx_dokploy/cli.py +38 -0
- apx_dokploy-0.1.0/apx_dokploy/client.py +144 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/cloud/dokploy/cookiecutter.json +14 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/cloud/dokploy/hooks/post_gen_project.py +9 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/cloud/dokploy/{{cookiecutter.project_slug}}/.dockerignore +11 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/cloud/dokploy/{{cookiecutter.project_slug}}/.github/workflows/docker-publish.yml +52 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/cloud/dokploy/{{cookiecutter.project_slug}}/DEPLOY.md +42 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/cloud/dokploy/{{cookiecutter.project_slug}}/Dockerfile +26 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/cloud/dokploy/{{cookiecutter.project_slug}}/docker-compose.yml +9 -0
- apx_dokploy-0.1.0/apx_dokploy/overlays/index.json +10 -0
- apx_dokploy-0.1.0/apx_dokploy/plugin.py +64 -0
- apx_dokploy-0.1.0/apx_dokploy/settings.py +46 -0
- apx_dokploy-0.1.0/apx_dokploy/target.py +555 -0
- apx_dokploy-0.1.0/apx_dokploy/tools.py +104 -0
- apx_dokploy-0.1.0/apx_dokploy.egg-info/PKG-INFO +87 -0
- apx_dokploy-0.1.0/apx_dokploy.egg-info/SOURCES.txt +26 -0
- apx_dokploy-0.1.0/apx_dokploy.egg-info/dependency_links.txt +1 -0
- apx_dokploy-0.1.0/apx_dokploy.egg-info/entry_points.txt +5 -0
- apx_dokploy-0.1.0/apx_dokploy.egg-info/requires.txt +6 -0
- apx_dokploy-0.1.0/apx_dokploy.egg-info/top_level.txt +1 -0
- apx_dokploy-0.1.0/pyproject.toml +38 -0
- apx_dokploy-0.1.0/setup.cfg +4 -0
- apx_dokploy-0.1.0/tests/test_plugin.py +61 -0
- apx_dokploy-0.1.0/tests/test_target.py +269 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may accept a fee in exchange for,
|
|
167
|
+
acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf
|
|
170
|
+
and on Your sole responsibility, not on behalf of any other
|
|
171
|
+
Contributor, and only if You agree to indemnify, defend, and hold
|
|
172
|
+
each Contributor harmless for any liability incurred by, or claims
|
|
173
|
+
asserted against, such Contributor by reason of your accepting any
|
|
174
|
+
such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same page as the copyright notice for easier identification within
|
|
187
|
+
the file itself.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Fernando Celmer
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apx-dokploy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dokploy for Action Platform: the dokploy deploy target (a Docker image the CI publishes, pulled by Dokploy), its overlay, readiness checks, and tools to read projects, applications and deployments.
|
|
5
|
+
Author-email: Action Platform <cloud@actionplatform.io>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: action-platform>=0.28.1
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
13
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
14
|
+
Requires-Dist: action-platform[mcp]; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# apx-dokploy
|
|
18
|
+
|
|
19
|
+
[Dokploy](https://dokploy.com) for [Action Platform](https://github.com/actionplatform/action-platform): the `dokploy` deploy target, its overlay, readiness checks, and tools that read what runs on the instance. `apx-` is the prefix every Action Platform extension carries.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
action-platform plugin install dokploy
|
|
23
|
+
export DOKPLOY_URL=… DOKPLOY_API_KEY=… # or Plugins → Dokploy → Configure on the platform
|
|
24
|
+
action-platform cloud set dokploy # Dockerfile, compose file, image workflow
|
|
25
|
+
action-platform deploy --dry-run # readiness: settings, image, key, application
|
|
26
|
+
action-platform deploy # point Dokploy at <image>:<version>, follow to done
|
|
27
|
+
action-platform diagnose
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## How it works
|
|
31
|
+
|
|
32
|
+
The build never runs on the platform or on Dokploy. The overlay's workflow publishes `ghcr.io/<owner>/<repo>:<version>` on every published release; the target tells Dokploy which tag to run and waits for the deployment to end. Every deployment therefore references a release, and rolling back is pointing at the previous tag.
|
|
33
|
+
|
|
34
|
+
| | |
|
|
35
|
+
|---|---|
|
|
36
|
+
| Overlay | `Dockerfile` (two stages on the [images-base](https://github.com/actionplatform/images-base) build and runtime images, `ap-build package`, port 8000), `.dockerignore`, `docker-compose.yml` for a machine, `.github/workflows/docker-publish.yml` (GitHub CI only), `DEPLOY.md`. One overlay for every language of the official `web/*` templates |
|
|
37
|
+
| Mapping | Dokploy project = `[project] name`; environment = the scope (`dev`, `prod`); application = `<name>-<scope>`. `create` and the first `deploy` provision what is missing, the domain included when `[deploy.domains]` names one |
|
|
38
|
+
| Readiness | `dokploy.settings` (url, key, image known), `image.published` (a manifest HEAD at the registry, following the bearer challenge), `dokploy.credentials` (the key opens `project.all`), `dokploy.application` (exists, not mid-deployment). The platform runs it after every release and refuses a blocked deploy |
|
|
39
|
+
| Deploy | `application.saveDockerProvider` with `<image>:<version>`, `application.deploy` titled `v<version>`, then `application.one` until `done` or `error` (15 minutes at most). Every step reaches the platform's run log |
|
|
40
|
+
| Rollback | the previous `done` deployment titled `v<version>` in the history, or the version asked for, deployed again |
|
|
41
|
+
| Diagnose | status, image, version and url of the scope's application |
|
|
42
|
+
| Delete | `application.delete` of the scope's application |
|
|
43
|
+
| Tools | `dokploy_projects`, `dokploy_applications`, `dokploy_deployments` |
|
|
44
|
+
| Commands | `action-platform dokploy projects\|applications\|deployments` |
|
|
45
|
+
|
|
46
|
+
## Configuration
|
|
47
|
+
|
|
48
|
+
`platform.toml`:
|
|
49
|
+
|
|
50
|
+
```toml
|
|
51
|
+
[deploy]
|
|
52
|
+
target = "dokploy"
|
|
53
|
+
# url = "https://dokploy.example.com" # overrides the plugin option
|
|
54
|
+
# image = "ghcr.io/acme/shop" # default: ghcr.io/<[source_host] repo>
|
|
55
|
+
# project = "shop" # default: [project] name
|
|
56
|
+
# application = "shop" # default: [project] name
|
|
57
|
+
# port = 8000
|
|
58
|
+
|
|
59
|
+
[deploy.domains]
|
|
60
|
+
prod = "shop.example.com"
|
|
61
|
+
dev = "shop-dev.example.com"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Plugin options (Plugins → Dokploy → Configure on the platform; on a machine, the environment or `~/.action-platform/plugins/dokploy.json`):
|
|
65
|
+
|
|
66
|
+
| Option | Environment | |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| `url` | `DOKPLOY_URL` | where the dashboard answers. Order on a machine: `[deploy]`, `AP_DOKPLOY_URL`, `DOKPLOY_URL`, the options file |
|
|
69
|
+
| `api_key` | `DOKPLOY_API_KEY` | Settings → API Keys in Dokploy. Never in `platform.toml` |
|
|
70
|
+
| `registry_username`, `registry_password` | `AP_DOKPLOY_REGISTRY_*` | only for a private image; a GitHub token with `read:packages` for ghcr.io |
|
|
71
|
+
|
|
72
|
+
A deploy job carries the options as `AP_DOKPLOY_<KEY>`.
|
|
73
|
+
|
|
74
|
+
## Requirements
|
|
75
|
+
|
|
76
|
+
- Dokploy 0.20 or newer (projects with environments; `application.saveDockerProvider`).
|
|
77
|
+
- The image published before the deploy: on GitHub, the overlay's workflow does it on every release. Another CI publishes `<image>:<version>` itself; the `image.published` check waits for it.
|
|
78
|
+
- The container listens on `$PORT` (8000 in the overlay's Dockerfile).
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install -e ".[dev]"
|
|
84
|
+
ruff check . && ruff format --check . && pytest
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Tests never reach the network: `tests/fake.py` is a Dokploy in memory.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# apx-dokploy
|
|
2
|
+
|
|
3
|
+
[Dokploy](https://dokploy.com) for [Action Platform](https://github.com/actionplatform/action-platform): the `dokploy` deploy target, its overlay, readiness checks, and tools that read what runs on the instance. `apx-` is the prefix every Action Platform extension carries.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
action-platform plugin install dokploy
|
|
7
|
+
export DOKPLOY_URL=… DOKPLOY_API_KEY=… # or Plugins → Dokploy → Configure on the platform
|
|
8
|
+
action-platform cloud set dokploy # Dockerfile, compose file, image workflow
|
|
9
|
+
action-platform deploy --dry-run # readiness: settings, image, key, application
|
|
10
|
+
action-platform deploy # point Dokploy at <image>:<version>, follow to done
|
|
11
|
+
action-platform diagnose
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## How it works
|
|
15
|
+
|
|
16
|
+
The build never runs on the platform or on Dokploy. The overlay's workflow publishes `ghcr.io/<owner>/<repo>:<version>` on every published release; the target tells Dokploy which tag to run and waits for the deployment to end. Every deployment therefore references a release, and rolling back is pointing at the previous tag.
|
|
17
|
+
|
|
18
|
+
| | |
|
|
19
|
+
|---|---|
|
|
20
|
+
| Overlay | `Dockerfile` (two stages on the [images-base](https://github.com/actionplatform/images-base) build and runtime images, `ap-build package`, port 8000), `.dockerignore`, `docker-compose.yml` for a machine, `.github/workflows/docker-publish.yml` (GitHub CI only), `DEPLOY.md`. One overlay for every language of the official `web/*` templates |
|
|
21
|
+
| Mapping | Dokploy project = `[project] name`; environment = the scope (`dev`, `prod`); application = `<name>-<scope>`. `create` and the first `deploy` provision what is missing, the domain included when `[deploy.domains]` names one |
|
|
22
|
+
| Readiness | `dokploy.settings` (url, key, image known), `image.published` (a manifest HEAD at the registry, following the bearer challenge), `dokploy.credentials` (the key opens `project.all`), `dokploy.application` (exists, not mid-deployment). The platform runs it after every release and refuses a blocked deploy |
|
|
23
|
+
| Deploy | `application.saveDockerProvider` with `<image>:<version>`, `application.deploy` titled `v<version>`, then `application.one` until `done` or `error` (15 minutes at most). Every step reaches the platform's run log |
|
|
24
|
+
| Rollback | the previous `done` deployment titled `v<version>` in the history, or the version asked for, deployed again |
|
|
25
|
+
| Diagnose | status, image, version and url of the scope's application |
|
|
26
|
+
| Delete | `application.delete` of the scope's application |
|
|
27
|
+
| Tools | `dokploy_projects`, `dokploy_applications`, `dokploy_deployments` |
|
|
28
|
+
| Commands | `action-platform dokploy projects\|applications\|deployments` |
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
`platform.toml`:
|
|
33
|
+
|
|
34
|
+
```toml
|
|
35
|
+
[deploy]
|
|
36
|
+
target = "dokploy"
|
|
37
|
+
# url = "https://dokploy.example.com" # overrides the plugin option
|
|
38
|
+
# image = "ghcr.io/acme/shop" # default: ghcr.io/<[source_host] repo>
|
|
39
|
+
# project = "shop" # default: [project] name
|
|
40
|
+
# application = "shop" # default: [project] name
|
|
41
|
+
# port = 8000
|
|
42
|
+
|
|
43
|
+
[deploy.domains]
|
|
44
|
+
prod = "shop.example.com"
|
|
45
|
+
dev = "shop-dev.example.com"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Plugin options (Plugins → Dokploy → Configure on the platform; on a machine, the environment or `~/.action-platform/plugins/dokploy.json`):
|
|
49
|
+
|
|
50
|
+
| Option | Environment | |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `url` | `DOKPLOY_URL` | where the dashboard answers. Order on a machine: `[deploy]`, `AP_DOKPLOY_URL`, `DOKPLOY_URL`, the options file |
|
|
53
|
+
| `api_key` | `DOKPLOY_API_KEY` | Settings → API Keys in Dokploy. Never in `platform.toml` |
|
|
54
|
+
| `registry_username`, `registry_password` | `AP_DOKPLOY_REGISTRY_*` | only for a private image; a GitHub token with `read:packages` for ghcr.io |
|
|
55
|
+
|
|
56
|
+
A deploy job carries the options as `AP_DOKPLOY_<KEY>`.
|
|
57
|
+
|
|
58
|
+
## Requirements
|
|
59
|
+
|
|
60
|
+
- Dokploy 0.20 or newer (projects with environments; `application.saveDockerProvider`).
|
|
61
|
+
- The image published before the deploy: on GitHub, the overlay's workflow does it on every release. Another CI publishes `<image>:<version>` itself; the `image.published` check waits for it.
|
|
62
|
+
- The container listens on `$PORT` (8000 in the overlay's Dockerfile).
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install -e ".[dev]"
|
|
68
|
+
ruff check . && ruff format --check . && pytest
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Tests never reach the network: `tests/fake.py` is a Dokploy in memory.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""`action-platform dokploy …` — the same reads as the tools, from a terminal."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from apx_dokploy.settings import connect
|
|
10
|
+
from apx_dokploy.tools import applications_of, deployments_of, projects_of
|
|
11
|
+
|
|
12
|
+
app = typer.Typer(
|
|
13
|
+
help="Dokploy: projects, applications, deployments.", no_args_is_help=True
|
|
14
|
+
)
|
|
15
|
+
options: Any | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@app.command("projects")
|
|
19
|
+
def projects() -> None:
|
|
20
|
+
"""List the projects and their environments."""
|
|
21
|
+
for p in projects_of(connect(options)):
|
|
22
|
+
typer.echo(f"{p.name}\t{', '.join(p.environments)}\t{p.id}")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@app.command("applications")
|
|
26
|
+
def applications(project: str = typer.Option("", help="Only this project")) -> None:
|
|
27
|
+
"""List the applications, their status and image."""
|
|
28
|
+
for a in applications_of(connect(options), project):
|
|
29
|
+
typer.echo(
|
|
30
|
+
f"{a.project}/{a.environment}/{a.app_name}\t{a.status}\t{a.image or '-'}\t{a.id}"
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@app.command("deployments")
|
|
35
|
+
def deployments(application_id: str, limit: int = typer.Option(10)) -> None:
|
|
36
|
+
"""Deployment history of one application."""
|
|
37
|
+
for d in deployments_of(connect(options), application_id, limit):
|
|
38
|
+
typer.echo(f"{d.created_at}\t{d.status}\t{d.title or '-'}\t{d.id}")
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""The Dokploy REST API (`/api/<router>.<procedure>`, `x-api-key`) and the OCI registry the image lives in — plain urllib, no client library."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
import json
|
|
7
|
+
import re
|
|
8
|
+
from typing import Any
|
|
9
|
+
from urllib import error, parse, request
|
|
10
|
+
|
|
11
|
+
from action_platform.core.exception import DeployError
|
|
12
|
+
|
|
13
|
+
TIMEOUT = 30
|
|
14
|
+
MANIFEST_TYPES = ", ".join(
|
|
15
|
+
[
|
|
16
|
+
"application/vnd.oci.image.index.v1+json",
|
|
17
|
+
"application/vnd.oci.image.manifest.v1+json",
|
|
18
|
+
"application/vnd.docker.distribution.manifest.list.v2+json",
|
|
19
|
+
"application/vnd.docker.distribution.manifest.v2+json",
|
|
20
|
+
]
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ApiError(DeployError):
|
|
25
|
+
def __init__(self, status: int, detail: str) -> None:
|
|
26
|
+
super().__init__(f"dokploy answered {status}: {detail}")
|
|
27
|
+
self.status = status
|
|
28
|
+
self.detail = detail
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Dokploy:
|
|
32
|
+
"""One Dokploy instance: `get` and `post` against its API with the key."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, url: str, api_key: str) -> None:
|
|
35
|
+
self.url = url.rstrip("/")
|
|
36
|
+
self.api_key = api_key
|
|
37
|
+
|
|
38
|
+
def get(self, procedure: str, **query: Any) -> Any:
|
|
39
|
+
target = f"{self.url}/api/{procedure}"
|
|
40
|
+
|
|
41
|
+
if query:
|
|
42
|
+
target += "?" + parse.urlencode(query)
|
|
43
|
+
|
|
44
|
+
return self._send("GET", target, None)
|
|
45
|
+
|
|
46
|
+
def post(self, procedure: str, body: dict[str, Any] | None = None) -> Any:
|
|
47
|
+
return self._send("POST", f"{self.url}/api/{procedure}", body or {})
|
|
48
|
+
|
|
49
|
+
def _send(self, method: str, target: str, body: dict[str, Any] | None) -> Any:
|
|
50
|
+
data = json.dumps(body).encode() if body is not None else None
|
|
51
|
+
req = request.Request(target, data=data, method=method)
|
|
52
|
+
req.add_header("x-api-key", self.api_key)
|
|
53
|
+
req.add_header("accept", "application/json")
|
|
54
|
+
|
|
55
|
+
if data is not None:
|
|
56
|
+
req.add_header("content-type", "application/json")
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
with request.urlopen(req, timeout=TIMEOUT) as response:
|
|
60
|
+
text = response.read().decode(errors="replace")
|
|
61
|
+
except error.HTTPError as e:
|
|
62
|
+
raise ApiError(e.code, e.read().decode(errors="replace")[:500]) from e
|
|
63
|
+
except (error.URLError, TimeoutError) as e:
|
|
64
|
+
raise DeployError(f"dokploy unreachable at {self.url}: {e}") from e
|
|
65
|
+
|
|
66
|
+
return json.loads(text) if text.strip() else None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def image_exists(
|
|
70
|
+
image: str,
|
|
71
|
+
tag: str,
|
|
72
|
+
username: str | None = None,
|
|
73
|
+
password: str | None = None,
|
|
74
|
+
) -> bool:
|
|
75
|
+
"""Whether `image:tag` is in its registry — a manifest HEAD, with the bearer token the registry asks for when it asks for one."""
|
|
76
|
+
registry, name = _split(image)
|
|
77
|
+
target = f"https://{registry}/v2/{name}/manifests/{tag}"
|
|
78
|
+
basic = (
|
|
79
|
+
base64.b64encode(f"{username}:{password}".encode()).decode()
|
|
80
|
+
if username and password
|
|
81
|
+
else None
|
|
82
|
+
)
|
|
83
|
+
status, challenge = _head(target, "Basic " + basic if basic else None)
|
|
84
|
+
|
|
85
|
+
if status == 401 and challenge:
|
|
86
|
+
token = _token(challenge, basic)
|
|
87
|
+
status, _ = _head(target, f"Bearer {token}")
|
|
88
|
+
|
|
89
|
+
if status == 200:
|
|
90
|
+
return True
|
|
91
|
+
|
|
92
|
+
if status == 404:
|
|
93
|
+
return False
|
|
94
|
+
|
|
95
|
+
raise DeployError(f"registry {registry} answered {status} for {name}:{tag}")
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _split(image: str) -> tuple[str, str]:
|
|
99
|
+
head, _, rest = image.partition("/")
|
|
100
|
+
|
|
101
|
+
if rest and ("." in head or ":" in head or head == "localhost"):
|
|
102
|
+
return head, rest
|
|
103
|
+
|
|
104
|
+
name = image if "/" in image else f"library/{image}"
|
|
105
|
+
|
|
106
|
+
return "registry-1.docker.io", name
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _head(target: str, authorization: str | None) -> tuple[int, str]:
|
|
110
|
+
req = request.Request(target, method="HEAD")
|
|
111
|
+
req.add_header("accept", MANIFEST_TYPES)
|
|
112
|
+
|
|
113
|
+
if authorization:
|
|
114
|
+
req.add_header("authorization", authorization)
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
with request.urlopen(req, timeout=TIMEOUT) as response:
|
|
118
|
+
return response.status, ""
|
|
119
|
+
except error.HTTPError as e:
|
|
120
|
+
return e.code, e.headers.get("www-authenticate", "")
|
|
121
|
+
except (error.URLError, TimeoutError) as e:
|
|
122
|
+
raise DeployError(f"registry unreachable: {e}") from e
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _token(challenge: str, basic: str | None) -> str:
|
|
126
|
+
fields = dict(re.findall(r'(\w+)="([^"]*)"', challenge))
|
|
127
|
+
realm = fields.get("realm")
|
|
128
|
+
|
|
129
|
+
if not realm:
|
|
130
|
+
raise DeployError(f"registry challenge not understood: {challenge}")
|
|
131
|
+
|
|
132
|
+
query = {k: v for k, v in fields.items() if k in ("service", "scope")}
|
|
133
|
+
req = request.Request(f"{realm}?{parse.urlencode(query)}")
|
|
134
|
+
|
|
135
|
+
if basic:
|
|
136
|
+
req.add_header("authorization", f"Basic {basic}")
|
|
137
|
+
|
|
138
|
+
try:
|
|
139
|
+
with request.urlopen(req, timeout=TIMEOUT) as response:
|
|
140
|
+
data = json.loads(response.read().decode())
|
|
141
|
+
except error.HTTPError as e:
|
|
142
|
+
raise DeployError(f"registry token refused ({e.code}): check the credentials")
|
|
143
|
+
|
|
144
|
+
return data.get("token") or data.get("access_token") or ""
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"project_name": "My Project",
|
|
3
|
+
"project_slug": "{{ cookiecutter.project_name|lower|replace(' ', '-') }}",
|
|
4
|
+
"github_owner": "actionplatform",
|
|
5
|
+
"package_name": "{{ cookiecutter.project_slug|replace('-', '_') }}",
|
|
6
|
+
"language": ["python", "node", "go", "java", "kotlin", "ruby"],
|
|
7
|
+
"type": ["web"],
|
|
8
|
+
"ci": ["github", "gitlab", "jenkins"],
|
|
9
|
+
"_kind": "cloud",
|
|
10
|
+
"_cloud": "dokploy",
|
|
11
|
+
"_description": "Docker image published by the CI on every release, run by Dokploy",
|
|
12
|
+
"_types": ["web"],
|
|
13
|
+
"_copy_without_render": [".github/workflows/docker-publish.yml"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Package Docker
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
packages: write
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: image-${{ github.ref_name }}
|
|
14
|
+
cancel-in-progress: false
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
name: Build and push ${{ github.ref_name }}
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Read the version from the tag
|
|
24
|
+
id: version
|
|
25
|
+
run: |
|
|
26
|
+
tag="${GITHUB_REF_NAME}"
|
|
27
|
+
version="${tag#v}"
|
|
28
|
+
[ "$version" = "$tag" ] && version="$(cat LAST_VERSION)"
|
|
29
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
30
|
+
echo "image=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
|
|
31
|
+
|
|
32
|
+
- uses: docker/setup-qemu-action@v3
|
|
33
|
+
- uses: docker/setup-buildx-action@v3
|
|
34
|
+
|
|
35
|
+
- uses: docker/login-action@v3
|
|
36
|
+
with:
|
|
37
|
+
registry: ghcr.io
|
|
38
|
+
username: ${{ github.actor }}
|
|
39
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
40
|
+
|
|
41
|
+
- uses: docker/build-push-action@v6
|
|
42
|
+
with:
|
|
43
|
+
context: .
|
|
44
|
+
platforms: linux/amd64,linux/arm64
|
|
45
|
+
push: true
|
|
46
|
+
tags: |
|
|
47
|
+
${{ steps.version.outputs.image }}:${{ steps.version.outputs.version }}
|
|
48
|
+
${{ steps.version.outputs.image }}:latest
|
|
49
|
+
cache-from: type=gha
|
|
50
|
+
cache-to: type=gha,mode=max
|
|
51
|
+
|
|
52
|
+
- run: echo "${{ steps.version.outputs.image }}:${{ steps.version.outputs.version }}" >> "$GITHUB_STEP_SUMMARY"
|