Skip to content

Commit 030302c

Browse files
committed
feat: add docker support
1 parent a569ca7 commit 030302c

8 files changed

Lines changed: 410 additions & 44 deletions

File tree

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build stage
2+
FROM golang:1.25-alpine AS builder
3+
4+
WORKDIR /app
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
8+
COPY . .
9+
RUN go build -o updatectl main.go
10+
11+
# Runtime stage
12+
FROM alpine:latest
13+
14+
# Install docker cli and git
15+
RUN apk add --no-cache docker-cli git
16+
17+
# Copy binary
18+
COPY --from=builder /app/updatectl /usr/local/bin/updatectl
19+
20+
# Create config directory
21+
RUN mkdir -p /etc/updatectl
22+
23+
# Set working directory
24+
WORKDIR /etc/updatectl
25+
26+
# Default command
27+
CMD ["updatectl", "watch"]

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# updatectl
22

33
A CLI tool for automating project updates. It periodically pulls the latest changes from Git repositories or checks for new Docker images and rebuilds/restarts projects based on their type (PM2, Docker, or Image).
4+
5+
> [!TIP]
6+
> For the best experience, run updatectl inside Docker. It can automatically discover and manage all your running containers.
7+
48
> [!WARNING]
59
> This project is very barebones and a work in progress and not ready for production use.
610
@@ -34,6 +38,10 @@ Run `updatectl init` to create the default configuration file and set up the dae
3438

3539
The daemon runs automatically after init. To run manually: `updatectl watch`
3640

41+
### List Projects
42+
43+
List configured projects: `updatectl list`
44+
3745
### View Logs
3846

3947
View daemon logs: `updatectl logs`
@@ -46,12 +54,12 @@ View daemon logs: `updatectl logs`
4654
Configuration is stored in:
4755

4856
- Linux: `/etc/updatectl/updatectl.yaml`
49-
- Windows: `%ProgramData%\updatectl\updatectl.yaml`
57+
- Windows: `%USERPROFILE%\updatectl\updatectl.yaml`
5058

5159
Example config:
5260

5361
```yaml
54-
intervalMinutes: 10
62+
interval: 600 # Check every 10 minutes (in seconds)
5563
projects:
5664
# Git-based Docker project
5765
- name: myapp
@@ -76,7 +84,8 @@ projects:
7684
containerName: my-dashboard
7785
```
7886
79-
- `intervalMinutes`: How often to check for updates (in minutes).
87+
- `interval`: How often to check for updates (in seconds). Recommended over `intervalMinutes`.
88+
- `intervalMinutes`: Deprecated. Use `interval` instead.
8089
- `projects`: List of projects to monitor.
8190
- `name`: Project name.
8291
- `path`: Local path to the project (required for git-based types).

docs/cli.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ updatectl [command]
1515
- `init` - Initialize configuration and daemon
1616
- `watch` - Run update daemon manually
1717
- `build` - Run build command for a specific project
18+
- `list` - List configured projects
1819
- `logs` - View updatectl daemon logs
1920
- `version` - Show version information
2021

@@ -48,6 +49,16 @@ updatectl build [project-name]
4849

4950
Executes the configured `buildCommand` for the specified project without pulling changes.
5051

52+
## list
53+
54+
List all configured projects.
55+
56+
```bash
57+
updatectl list
58+
```
59+
60+
Displays the name, type, and relevant details for each project in the configuration.
61+
5162
## logs
5263

5364
View logs from the updatectl daemon service.

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Updatectl uses a YAML configuration file to define update intervals and projects
55
## Location
66

77
- Linux: `/etc/updatectl/updatectl.yaml`
8-
- Windows: `%ProgramData%\updatectl\updatectl.yaml`
8+
- Windows: `%USERPROFILE%\updatectl\updatectl.yaml`
99

1010
## Schema
1111

docs/index.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,30 @@ layout: home
44

55
hero:
66
name: "Updatectl"
7-
text: "A CLI tool for automating project updates"
8-
tagline: Automate your project updates with ease
7+
text: "Docker Container Auto-Updater"
8+
tagline: Automatically update and restart your Docker containers
99
image:
1010
src: /logo.svg
1111
alt: Updatectl Logo
1212
actions:
1313
- theme: brand
1414
text: Get Started
15-
link: /guide
15+
link: /quickstart
1616
- theme: alt
1717
text: View on GitHub
1818
link: https://github.com/parcoil/updatectl
1919

2020
features:
21-
- title: Automated Updates
22-
icon: <span class="material-symbols-rounded ">cycle<span>
23-
details: Keep your projects up-to-date automatically with configurable schedules and project types.
24-
- title: Flexible Configuration
25-
icon: <span class="material-symbols-rounded">description<span>
26-
details: Support for various project types including Node.js using PM2, Python, Go, and more with docker.
27-
- title: Easy to Use
28-
icon: <span class="material-symbols-rounded">terminal<span>
29-
details: Simple CLI interface with comprehensive documentation and troubleshooting guides.
21+
- title: Container Auto-Discovery
22+
icon: <span class="material-symbols-rounded">search</span>
23+
details: Automatically discovers and monitors all running Docker containers with images from Docker Hub or GHCR.
24+
- title: Git & Image Support
25+
icon: <span class="material-symbols-rounded">code</span>
26+
details: Update Git-based projects or pull latest Docker images and restart containers when updates are available.
27+
- title: Docker-Native
28+
icon: <svg role="img" width="30" height="30" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Docker</title><path d="M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"/></svg>
29+
details: Runs inside Docker itself for seamless container management without host dependencies.
30+
- title: Cross-Platform
31+
icon: <span class="material-symbols-rounded">devices</span>
32+
details: Works on Linux (systemd) and Windows (Task Scheduler) with simple installation and configuration.
3033
---

docs/quickstart.md

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,28 @@ This guide will get you up and running with Updatectl in minutes.
44

55
## Prerequisites
66

7-
- Go installed
7+
- Go installed (for building from source)
88
- Git installed
99
- Docker or PM2 depending on your projects
10+
- Docker Compose (for containerized deployment)
1011

1112
## Installation
1213

13-
Download the latest release or build from source:
14+
### From Source
1415

1516
```bash
1617
go build -o updatectl
1718
sudo mv updatectl /usr/local/bin/
1819
```
1920

21+
### Using Docker
22+
23+
Pull the official Docker image:
24+
25+
```bash
26+
docker pull ghcr.io/parcoil/updatectl:latest
27+
```
28+
2029
## First Setup
2130

2231
1. Initialize the configuration:
@@ -32,7 +41,7 @@ sudo updatectl init
3241
For git-based projects:
3342

3443
```yaml
35-
intervalMinutes: 15
44+
interval: 900 # 15 minutes in seconds
3645
projects:
3746
- name: myproject
3847
path: /path/to/project
@@ -44,7 +53,7 @@ projects:
4453
For image-based projects (pre-built Docker images):
4554
4655
```yaml
47-
intervalMinutes: 15
56+
interval: 900 # 15 minutes in seconds
4857
projects:
4958
- name: my-app
5059
type: image
@@ -54,4 +63,91 @@ projects:
5463
NODE_ENV: production
5564
```
5665
57-
4. The daemon will start automatically and check for updates every 15 minutes.
66+
4. The daemon will start automatically and check for updates every 15 minutes.
67+
68+
## Recommended: Running with Docker Compose
69+
70+
> [!TIP]
71+
> Running updatectl inside Docker is the recommended approach. It provides isolation, automatic container discovery, and easy management.
72+
73+
When running in Docker, updatectl automatically discovers and manages all running containers with images from Docker Hub or GHCR. No manual configuration needed!
74+
75+
Create a `docker-compose.yml`:
76+
77+
```yaml
78+
version: '3.8'
79+
services:
80+
updatectl:
81+
image: ghcr.io/parcoil/updatectl:latest
82+
volumes:
83+
- /var/run/docker.sock:/var/run/docker.sock
84+
environment:
85+
- DOCKER_HOST=unix:///var/run/docker.sock
86+
- UPDATECTL_INTERVAL=600 # 10 minutes in seconds
87+
restart: unless-stopped
88+
89+
# Your other services...
90+
my-app:
91+
image: docker.io/my-app:latest
92+
ports:
93+
- "80:80"
94+
# ...
95+
```
96+
97+
Environment variables:
98+
- `UPDATECTL_INTERVAL`: Check interval in seconds (default: 600)
99+
100+
### Benefits of Docker Deployment
101+
102+
- **Automatic Discovery**: Finds all running containers automatically
103+
- **No Configuration**: Works out-of-the-box with existing containers
104+
- **Isolation**: Runs in its own container without affecting host system
105+
- **Easy Updates**: Update updatectl itself by rebuilding the image
106+
107+
### How It Works
108+
109+
Updatectl will automatically monitor all containers with `docker.io/`, `ghcr.io/`, or registry images and restart them when new versions are available. It inspects container ports and environment variables to preserve your configuration.
110+
111+
Then run:
112+
113+
```bash
114+
docker compose up -d
115+
```
116+
117+
Updatectl runs inside a container and controls Docker on the host via the mounted socket.
118+
119+
## Direct Docker Run (Without Compose)
120+
121+
If you prefer not to use Docker Compose, you can run updatectl directly with `docker run`.
122+
123+
### Linux
124+
125+
```bash
126+
docker run -d \
127+
--name updatectl \
128+
-e UPDATECTL_INTERVAL=30 \
129+
-v /var/run/docker.sock:/var/run/docker.sock \
130+
ghcr.io/parcoil/updatectl:latest
131+
```
132+
133+
### Windows (PowerShell)
134+
135+
```powershell
136+
docker run -d `
137+
--name updatectl `
138+
-e UPDATECTL_INTERVAL=30 `
139+
-v //./pipe/docker_engine://./pipe/docker_engine `
140+
-e DOCKER_HOST=npipe:////./pipe/docker_engine `
141+
ghcr.io/parcoil/updatectl:latest
142+
```
143+
144+
### Windows (Command Prompt)
145+
146+
```cmd
147+
docker run -d ^
148+
--name updatectl ^
149+
-e UPDATECTL_INTERVAL=30 ^
150+
-v //./pipe/docker_engine://./pipe/docker_engine ^
151+
-e DOCKER_HOST=npipe:////./pipe/docker_engine ^
152+
ghcr.io/parcoil/updatectl:latest
153+
```

docs/schema.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Detailed YAML configuration reference.
1010
| `intervalMinutes` | integer | No | **Deprecated**: Use `interval` instead |
1111
| `projects` | array | Yes | List of projects to monitor |
1212

13+
## Environment Variables (Docker)
14+
15+
When running in Docker, projects are auto-discovered from running containers with Docker Hub or GHCR images.
16+
17+
- `UPDATECTL_INTERVAL`: Check interval in seconds (default: 600)
18+
1319
## Project Object
1420

1521
| Field | Type | Required | Description |

0 commit comments

Comments
 (0)