|
1 | | -# pctl - Dev Companion for Portainer |
2 | | - |
3 | | -A simple CLI tool for quickly deploying and re-deploying your application on a Portainer environment. |
4 | | - |
5 | | -[](https://asciinema.org/a/zYM6Tu31LesuRowrLDJZfGzcU) |
6 | | - |
7 | | -## Usage |
8 | | - |
9 | | -### Prerequisites |
10 | | -- A `docker-compose.yml` file in your project directory |
11 | | -- Portainer instance with API access |
12 | | -- Portainer API token (generate in Portainer: Settings > API Keys) |
13 | | - |
14 | | -### 1. Initialize Configuration |
15 | | -```bash |
16 | | -pctl init |
17 | | -``` |
18 | | -Interactive setup to configure your Portainer connection (URL, API token, environment). This creates a `pctl.yml` configuration file. |
19 | | - |
20 | | -### 2. Deploy Your Application |
21 | | -```bash |
22 | | -pctl deploy |
23 | | -``` |
24 | | -Deploy your Docker Compose stack to Portainer. The tool reads your `docker-compose.yml` file and creates a new stack. |
25 | | - |
26 | | -**Build Support**: If your compose file contains `build:` directives, pctl will automatically build the images before deployment. See the [Build Configuration](#build-configuration) section for details. |
27 | | - |
28 | | -### 3. Update Existing Stack |
29 | | -```bash |
30 | | -pctl redeploy |
31 | | -``` |
32 | | -Update an existing stack with latest images. |
33 | | - |
34 | | -**Force Rebuild**: Use the `-f` or `--force-rebuild` flag to force rebuild images even if they haven't changed: |
35 | | -```bash |
36 | | -pctl redeploy -f |
37 | | -``` |
38 | | -This sets `force_build=true` for this run, which includes no-cache behavior, ensuring a complete rebuild of all images. |
39 | | - |
40 | | -### 4. Check Status |
41 | | -```bash |
42 | | -pctl ps |
43 | | -``` |
44 | | -View stack status and running containers. |
45 | | - |
46 | | -### 5. View Logs |
47 | | -```bash |
48 | | -pctl logs |
49 | | -``` |
50 | | -Stream real-time logs from your containers. |
51 | | - |
52 | | -**Log Options**: |
53 | | -- `-t, --tail N`: Show the last N lines from the end of logs (default: 50) |
54 | | -- `-s, --service NAME`: Show logs from a specific service only |
55 | | - |
56 | | -Examples: |
57 | | -```bash |
58 | | -# Show last 100 lines from all containers |
59 | | -pctl logs -t 100 |
60 | | - |
61 | | -# Show logs from a specific service |
62 | | -pctl logs -s web |
63 | | - |
64 | | -# Show last 20 lines from the database service |
65 | | -pctl logs -s database -t 20 |
66 | | -``` |
67 | | - |
68 | | -### 6. Check Version |
69 | | -```bash |
70 | | -pctl version |
71 | | -``` |
72 | | -Display version information including version number, git commit hash, build timestamp, Go version, and target platform. |
73 | | - |
74 | | -## Configuration |
75 | | - |
76 | | -pctl uses a `pctl.yml` configuration file created during initialization: |
77 | | - |
78 | | -```yaml |
79 | | -portainer_url: https://portainer.example.com |
80 | | -api_token: ptr_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
81 | | -environment_id: 1 |
82 | | -stack_name: pctl_myproject |
83 | | -compose_file: docker-compose.yml |
84 | | -skip_tls_verify: true |
85 | | -``` |
86 | | -
|
87 | | -The configuration includes: |
88 | | -- **portainer_url**: Your Portainer instance URL |
89 | | -- **api_token**: Portainer API token (starts with `ptr_`) |
90 | | -- **environment_id**: Portainer environment ID |
91 | | -- **stack_name**: Name for your stack in Portainer |
92 | | -- **compose_file**: Path to your Docker Compose file |
93 | | -- **skip_tls_verify**: Skip TLS verification for self-hosted instances |
94 | | - |
95 | | -## Build Configuration |
96 | | - |
97 | | -When using `build:` directives in your compose file, pctl can automatically build images before deployment. Add a `build` section to your `pctl.yml`: |
98 | | - |
99 | | -```yaml |
100 | | -build: |
101 | | - mode: remote-build # remote-build (default) or load |
102 | | - parallel: auto # concurrent builds (auto or number) |
103 | | - tag_format: "pctl-{{stack}}-{{service}}:{{hash}}" |
104 | | - platforms: ["linux/amd64"] # for load mode |
105 | | - extra_build_args: {} # global build args |
106 | | - force_build: false # force rebuild even if unchanged |
107 | | - warn_threshold_mb: 50 # warn if context > 50MB |
108 | | -``` |
109 | | - |
110 | | -### Build Modes |
111 | | - |
112 | | -- **remote-build** (default): Builds images on the remote Docker engine via Portainer's Docker proxy. Most bandwidth-efficient. |
113 | | -- **load**: Builds images locally and uploads them to the remote engine. Useful when the remote has poor internet access. |
114 | | - |
115 | | -### Example Compose with Build |
116 | | - |
117 | | -```yaml |
118 | | -version: '3.8' |
119 | | -services: |
120 | | - web: |
121 | | - build: |
122 | | - context: ./web |
123 | | - dockerfile: Dockerfile |
124 | | - args: |
125 | | - NODE_ENV: production |
126 | | - ports: |
127 | | - - "3000:3000" |
128 | | - |
129 | | - api: |
130 | | - build: ./api |
131 | | - ports: |
132 | | - - "8080:8080" |
133 | | -``` |
134 | | - |
135 | | -When you run `pctl deploy`, it will: |
136 | | -1. Detect the `build:` directives |
137 | | -2. Build the images according to your build configuration |
138 | | -3. Transform the compose file to use the built images |
139 | | -4. Deploy the stack to Portainer |
140 | | - |
141 | | -## Installation |
142 | | - |
143 | | -Download the latest release for your platform from [GitHub Releases](https://github.com/deviantony/pctl/releases/latest): |
144 | | - |
145 | | -### Linux |
146 | | -```bash |
147 | | -# AMD64 |
148 | | -wget https://github.com/deviantony/pctl/releases/latest/download/pctl_1.2.0_linux_amd64.tar.gz |
149 | | -tar -xzf pctl_1.2.0_linux_amd64.tar.gz |
150 | | -chmod +x pctl |
151 | | -sudo mv pctl /usr/local/bin/ |
152 | | -
|
153 | | -# ARM64 |
154 | | -wget https://github.com/deviantony/pctl/releases/latest/download/pctl_1.2.0_linux_arm64.tar.gz |
155 | | -tar -xzf pctl_1.2.0_linux_arm64.tar.gz |
156 | | -chmod +x pctl |
157 | | -sudo mv pctl /usr/local/bin/ |
158 | | -``` |
159 | | - |
160 | | -### macOS |
161 | | -```bash |
162 | | -# AMD64 |
163 | | -wget https://github.com/deviantony/pctl/releases/latest/download/pctl_1.2.0_darwin_amd64.tar.gz |
164 | | -tar -xzf pctl_1.2.0_darwin_amd64.tar.gz |
165 | | -chmod +x pctl |
166 | | -sudo mv pctl /usr/local/bin/ |
167 | | -
|
168 | | -# ARM64 (Apple Silicon) |
169 | | -wget https://github.com/deviantony/pctl/releases/latest/download/pctl_1.2.0_darwin_arm64.tar.gz |
170 | | -tar -xzf pctl_1.2.0_darwin_arm64.tar.gz |
171 | | -chmod +x pctl |
172 | | -sudo mv pctl /usr/local/bin/ |
173 | | -``` |
174 | | - |
175 | | -### Windows |
176 | | -```bash |
177 | | -# AMD64 |
178 | | -wget https://github.com/deviantony/pctl/releases/latest/download/pctl_1.2.0_windows_amd64.zip |
179 | | -# Extract the zip file and move pctl.exe to your PATH |
180 | | -``` |
181 | | - |
182 | | -## Development |
183 | | - |
184 | | -### Creating Releases |
185 | | - |
186 | | -Releases are automated using [GoReleaser](https://goreleaser.com/) and GitHub Actions. To create a new release: |
187 | | - |
188 | | -```bash |
189 | | -# Create a new release (e.g., version 1.2.0) |
190 | | -./scripts/release.sh 1.2.0 |
191 | | -
|
192 | | -# Dry run to see what would happen |
193 | | -./scripts/release.sh 1.2.0 --dry-run |
194 | | -``` |
195 | | - |
196 | | -This will: |
197 | | -1. Create a git tag `v1.2.0` |
198 | | -2. Push the tag to GitHub |
199 | | -3. GoReleaser automatically builds binaries for all platforms |
200 | | -4. Creates a GitHub release with all binaries, checksums, and release notes |
201 | | - |
202 | | -See [RELEASE.md](RELEASE.md) for detailed release process documentation. |
203 | | - |
204 | | -## Limitations |
205 | | - |
206 | | -- **Docker Standalone environments only** - Full support for Kubernetes environments is planned for future versions. |
| 1 | +<p align="center"> |
| 2 | + <img alt="GoReleaser Logo" src="https://avatars2.githubusercontent.com/u/24697112?v=3&s=200" height="140" /> |
| 3 | + <h3 align="center">GoReleaser</h3> |
| 4 | + <p align="center">Deliver Go binaries as fast and easily as possible.</p> |
| 5 | +</p> |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +GoReleaser builds Go binaries for several platforms, creates a GitHub release and then |
| 10 | +pushes a Homebrew formula to a tap repository. All that wrapped in your favorite CI. |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Get GoReleaser |
| 17 | + |
| 18 | +- [On your machine](https://goreleaser.com/install/); |
| 19 | +- [On CI/CD systems](https://goreleaser.com/ci/). |
| 20 | + |
| 21 | +## Documentation |
| 22 | + |
| 23 | +Documentation is hosted live at https://goreleaser.com |
| 24 | + |
| 25 | +## Community |
| 26 | + |
| 27 | +You have questions, need support and or just want to talk about GoReleaser? |
| 28 | + |
| 29 | +Here are ways to get in touch with the GoReleaser community: |
| 30 | + |
| 31 | +[](https://discord.gg/RGEBtg8vQ6) |
| 32 | +[](https://twitter.com/goreleaser) |
| 33 | +[](https://github.com/goreleaser/goreleaser/discussions) |
| 34 | + |
| 35 | +You can find the links above and all others [here](https://goreleaser.com/links/). |
| 36 | + |
| 37 | +### Code of Conduct |
| 38 | + |
| 39 | +This project adheres to the Contributor Covenant [code of conduct](https://github.com/goreleaser/.github/blob/main/CODE_OF_CONDUCT.md). |
| 40 | +By participating, you are expected to uphold this code. |
| 41 | +We appreciate your contribution. |
| 42 | +Please refer to our [contributing guidelines](CONTRIBUTING.md) for further information. |
| 43 | + |
| 44 | +## Badges |
| 45 | + |
| 46 | +[](https://github.com/goreleaser/goreleaser/releases/latest) |
| 47 | +[](/LICENSE.md) |
| 48 | +[](https://github.com/goreleaser/goreleaser/actions?workflow=build) |
| 49 | +[](https://codecov.io/gh/goreleaser/goreleaser) |
| 50 | +[](https://artifacthub.io/packages/search?repo=goreleaser) |
| 51 | +[](http://godoc.org/github.com/goreleaser/goreleaser) |
| 52 | +[](https://github.com/goreleaser) |
| 53 | +[](https://opencollective.com/goreleaser/backers/) |
| 54 | +[](https://opencollective.com/goreleaser/sponsors/) |
| 55 | +[](https://conventionalcommits.org) |
| 56 | +[](https://bestpractices.coreinfrastructure.org/projects/5420) |
| 57 | + |
| 58 | +## GitHub Sponsors |
| 59 | + |
| 60 | +High-tier sponsors of [@caarlos0](https://github.com/sponsors/caarlos0/) on GitHub: |
| 61 | + |
| 62 | +<a href="https://smallstep.com" target="_blank"><img width="200" src="https://github.com/goreleaser/goreleaser/assets/245435/05ade839-6652-474a-af90-da3ea67dde24"></a> |
| 63 | + |
| 64 | +## OpenCollective |
| 65 | + |
| 66 | +### Sponsors |
| 67 | + |
| 68 | +Does your company use goreleaser? Help keep the project bug-free and feature rich by [sponsoring the project](https://opencollective.com/goreleaser#sponsor). |
| 69 | + |
| 70 | +<a href="https://opencollective.com/goreleaser/sponsors/0/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/0/avatar"></a> |
| 71 | +<a href="https://opencollective.com/goreleaser/sponsors/1/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/1/avatar"></a> |
| 72 | +<a href="https://opencollective.com/goreleaser/sponsors/2/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/2/avatar"></a> |
| 73 | +<a href="https://opencollective.com/goreleaser/sponsors/3/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/3/avatar"></a> |
| 74 | +<a href="https://opencollective.com/goreleaser/sponsors/4/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/4/avatar"></a> |
| 75 | +<a href="https://opencollective.com/goreleaser/sponsors/5/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/5/avatar"></a> |
| 76 | +<a href="https://opencollective.com/goreleaser/sponsors/6/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/6/avatar"></a> |
| 77 | +<a href="https://opencollective.com/goreleaser/sponsors/7/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/7/avatar"></a> |
| 78 | +<a href="https://opencollective.com/goreleaser/sponsors/8/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/8/avatar"></a> |
| 79 | +<a href="https://opencollective.com/goreleaser/sponsors/9/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/9/avatar"></a> |
| 80 | +<a href="https://opencollective.com/goreleaser/sponsors/10/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/10/avatar"></a> |
| 81 | +<a href="https://opencollective.com/goreleaser/sponsors/11/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/11/avatar"></a> |
| 82 | +<a href="https://opencollective.com/goreleaser/sponsors/12/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/12/avatar"></a> |
| 83 | +<a href="https://opencollective.com/goreleaser/sponsors/13/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/13/avatar"></a> |
| 84 | +<a href="https://opencollective.com/goreleaser/sponsors/14/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/14/avatar"></a> |
| 85 | +<a href="https://opencollective.com/goreleaser/sponsors/15/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/15/avatar"></a> |
| 86 | +<a href="https://opencollective.com/goreleaser/sponsors/16/website" target="_blank"><img src="https://opencollective.com/goreleaser/sponsors/16/avatar"></a> |
| 87 | + |
| 88 | +### Backers |
| 89 | + |
| 90 | +Love our work and community? [Become a backer](https://opencollective.com/goreleaser). |
| 91 | + |
| 92 | +<a href="https://opencollective.com/goreleaser/backers/0/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/0/avatar"></a> |
| 93 | +<a href="https://opencollective.com/goreleaser/backers/1/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/1/avatar"></a> |
| 94 | +<a href="https://opencollective.com/goreleaser/backers/2/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/2/avatar"></a> |
| 95 | +<a href="https://opencollective.com/goreleaser/backers/3/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/3/avatar"></a> |
| 96 | +<a href="https://opencollective.com/goreleaser/backers/4/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/4/avatar"></a> |
| 97 | +<a href="https://opencollective.com/goreleaser/backers/5/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/5/avatar"></a> |
| 98 | +<a href="https://opencollective.com/goreleaser/backers/6/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/6/avatar"></a> |
| 99 | +<a href="https://opencollective.com/goreleaser/backers/7/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/7/avatar"></a> |
| 100 | +<a href="https://opencollective.com/goreleaser/backers/8/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/8/avatar"></a> |
| 101 | +<a href="https://opencollective.com/goreleaser/backers/9/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/9/avatar"></a> |
| 102 | +<a href="https://opencollective.com/goreleaser/backers/10/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/10/avatar"></a> |
| 103 | +<a href="https://opencollective.com/goreleaser/backers/11/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/11/avatar"></a> |
| 104 | +<a href="https://opencollective.com/goreleaser/backers/12/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/12/avatar"></a> |
| 105 | +<a href="https://opencollective.com/goreleaser/backers/13/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/13/avatar"></a> |
| 106 | +<a href="https://opencollective.com/goreleaser/backers/14/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/14/avatar"></a> |
| 107 | +<a href="https://opencollective.com/goreleaser/backers/15/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/15/avatar"></a> |
| 108 | +<a href="https://opencollective.com/goreleaser/backers/16/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/16/avatar"></a> |
| 109 | +<a href="https://opencollective.com/goreleaser/backers/17/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/17/avatar"></a> |
| 110 | +<a href="https://opencollective.com/goreleaser/backers/18/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/18/avatar"></a> |
| 111 | +<a href="https://opencollective.com/goreleaser/backers/19/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/19/avatar"></a> |
| 112 | +<a href="https://opencollective.com/goreleaser/backers/20/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/20/avatar"></a> |
| 113 | +<a href="https://opencollective.com/goreleaser/backers/21/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/21/avatar"></a> |
| 114 | +<a href="https://opencollective.com/goreleaser/backers/22/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/22/avatar"></a> |
| 115 | +<a href="https://opencollective.com/goreleaser/backers/23/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/23/avatar"></a> |
| 116 | +<a href="https://opencollective.com/goreleaser/backers/24/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/24/avatar"></a> |
| 117 | +<a href="https://opencollective.com/goreleaser/backers/25/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/25/avatar"></a> |
| 118 | +<a href="https://opencollective.com/goreleaser/backers/26/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/26/avatar"></a> |
| 119 | +<a href="https://opencollective.com/goreleaser/backers/27/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/27/avatar"></a> |
| 120 | +<a href="https://opencollective.com/goreleaser/backers/28/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/28/avatar"></a> |
| 121 | +<a href="https://opencollective.com/goreleaser/backers/29/website" target="_blank"><img src="https://opencollective.com/goreleaser/backers/29/avatar"></a> |
| 122 | + |
| 123 | +### Contributors |
| 124 | + |
| 125 | +This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. |
| 126 | +<a href="https://github.com/goreleaser/goreleaser/graphs/contributors"><img src="https://opencollective.com/goreleaser/contributors.svg?width=890" /></a> |
| 127 | + |
| 128 | +## Stargazers over time |
| 129 | +[](https://starchart.cc/goreleaser/goreleaser) |
0 commit comments