Skip to content

Commit

Permalink
chore: Rename to dispenser
Browse files Browse the repository at this point in the history
  • Loading branch information
andyquinterom committed Oct 8, 2024
1 parent 73c6ca2 commit 79fdec2
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 115 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "compose-watcher"
name = "dispenser"
version = "0.1.0"
edition = "2021"
license = "MIT"
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.PHONY: build-deb build-rpm

WORK_DIR=$(shell pwd)
TARGET_BIN=target/x86_64-unknown-linux-musl/release/compose-watcher
USR_BIN_DEB=deb/usr/local/bin/compose-watcher
USR_BIN_RPM=rpm/usr/local/bin/compose-watcher
TARGET_BIN=target/x86_64-unknown-linux-musl/release/dispenser
USR_BIN_DEB=deb/usr/local/bin/dispenser
USR_BIN_RPM=rpm/usr/local/bin/dispenser

$(TARGET_BIN):
CARGO_TARGET_DIR="./target" cargo build --release --target "x86_64-unknown-linux-musl"
Expand All @@ -18,10 +18,10 @@ $(USR_BIN_DEB): $(TARGET_BIN)

build-deb: $(USR_BIN_DEB)
dpkg-deb --build deb
mv deb.deb compose-watcher.deb
mv deb.deb dispenser.deb

build-rpm: $(USR_BIN_RPM)
cp -r rpm/ rpmbuild
mkdir -p rpmbuild/opt/compose-watcher
mkdir -p rpmbuild/opt/dispenser
rpmbuild --target=x86_64 --buildroot $(WORK_DIR)/rpmbuild \
-bb rpmbuild/compose-watcher.spec
-bb rpmbuild/dispenser.spec
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Compose Watcher
# Dispenser

This tool manages Docker Compose instances by constantly looking for new
versions of images to deploying seemlessly.

Compose Watcher works as a daemon that runs in the background of the host server.
Dispenser works as a daemon that runs in the background of the host server.

## Build

Expand All @@ -23,7 +23,7 @@ make build-rpm
```


This should create a file called roughly `../compose-watcher-$VERSION.x86_64.rpm`.
This should create a file called roughly `../dispenser-$VERSION.x86_64.rpm`.

### Deb (Debian & Ubuntu)

Expand All @@ -40,5 +40,5 @@ Once these dependencies are installed run:
make build-deb
```

This should create a file called roughly `./compose-watcher.deb`.
This should create a file called roughly `./dispenser.deb`.

4 changes: 2 additions & 2 deletions deb/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: compose-watcher
Package: dispenser
Version: 0.1
Maintainer: ixpantia S.A.
Architecture: amd64
Description: Continously Deploy services with Docker Compose
Depends: docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, docker-compose-plugin
Depends: docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, docker-compose-plugin, gnupg2, pass
23 changes: 12 additions & 11 deletions deb/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#!/bin/sh
set -e

# Create the 'compose-watcher' user and home directory if it doesn't exist
if ! id -u compose-watcher > /dev/null 2>&1; then
useradd -r -d /opt/compose-watcher -s /bin/false compose-watcher
mkdir -p /opt/compose-watcher
chown compose-watcher:compose-watcher /opt/compose-watcher
# Create the 'dispenser' user and home directory if it doesn't exist
if ! id -u dispenser > /dev/null 2>&1; then
useradd -r -d /opt/dispenser -s /bin/bash dispenser
usermod -aG docker dispenser
mkdir -p /opt/dispenser
chown dispenser:dispenser /opt/dispenser
fi

# Create the compose-watcher.toml file if it doesn't exist
if [ ! -f /opt/compose-watcher/compose-watcher.toml ]; then
echo "delay=60 # Will watch for updates every 60 seconds" >> /opt/compose-watcher/compose-watcher.toml
chown compose-watcher:compose-watcher /opt/compose-watcher/compose-watcher.toml
# Create the dispenser.toml file if it doesn't exist
if [ ! -f /opt/dispenser/dispenser.toml ]; then
echo "delay=60 # Will watch for updates every 60 seconds" >> /opt/dispenser/dispenser.toml
chown dispenser:dispenser /opt/dispenser/dispenser.toml
fi

# Restart the service on upgrade
if [ "$1" = "configure" ]; then
systemctl daemon-reload || true
systemctl enable compose-watcher.service || true
systemctl start compose-watcher.service || true
systemctl enable dispenser.service || true
systemctl start dispenser.service || true
fi
10 changes: 5 additions & 5 deletions deb/DEBIAN/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ set -e

if [ "$1" = "purge" ]; then
systemctl daemon-reload || true
rm -f /lib/systemd/system/compose-watcher.service
rm -f /lib/systemd/system/dispenser.service
fi

rm -rf /usr/local/bin/compose-watcher
rm -rf /usr/local/bin/dispenser

if [ "$1" = "purge" ]; then
# Remove the compose-watcher user and its home directory
userdel -r compose-watcher || true
rm -rf /opt/compose-watcher
# Remove the dispenser user and its home directory
userdel -r dispenser || true
rm -rf /opt/dispenser
fi
4 changes: 2 additions & 2 deletions deb/DEBIAN/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -e

if [ "$1" = "remove" ]; then
systemctl stop compose-watcher.service || true
systemctl disable compose-watcher.service || true
systemctl stop dispenser.service || true
systemctl disable dispenser.service || true
fi
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ StartLimitIntervalSec=0
Type=simple
Restart=always
RestartSec=1
User=compose-watcher
User=dispenser
Environment="RUST_LOG=info"
ExecStart=/usr/local/bin/compose-watcher --config /opt/compose-watcher/compose-watcher.toml
ExecStart=/usr/local/bin/dispenser --config /opt/dispenser/dispenser.toml
ExecReload=/bin/kill -HUP $MAINPID
WorkingDirectory=/opt/compose-watcher
WorkingDirectory=/opt/dispenser

[Install]
WantedBy=multi-user.target
Binary file added deb/usr/local/bin/dispenser
Binary file not shown.
65 changes: 0 additions & 65 deletions rpm/compose-watcher.spec

This file was deleted.

65 changes: 65 additions & 0 deletions rpm/dispenser.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Name: dispenser
Version: 0.1
Release: 0
Summary: Continously Deploy services with Docker Compose
License: see /usr/share/doc/dispenser/copyright
Distribution: Debian
Group: Converted/unknown
Requires: docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin, gnupg2, pass

%define _rpmdir ./
%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%define _unpackaged_files_terminate_build 0

%post
#!/bin/sh
set -e

# Create the 'dispenser' user and home directory if it doesn't exist
if ! id -u dispenser > /dev/null 2>&1; then
useradd -r -d /opt/dispenser -s /bin/bash dispenser
usermod -aG docker dispenser
mkdir -p /opt/dispenser
chown dispenser:dispenser /opt/dispenser
fi

# Create the dispenser.toml file if it doesn't exist
if [ ! -f /opt/dispenser/dispenser.toml ]; then
echo "delay=60 # Will watch for updates every 60 seconds" >> /opt/dispenser/dispenser.toml
chown dispenser:dispenser /opt/dispenser/dispenser.toml
fi

# Restart the service on upgrade
systemctl daemon-reload || true
systemctl enable dispenser.service || true
systemctl start dispenser.service || true


%preun
#!/bin/sh
set -e

systemctl stop dispenser.service || true
systemctl disable dispenser.service || true


%postun
#!/bin/sh
set -e

systemctl daemon-reload || true
rm -f /lib/systemd/system/dispenser.service

rm -rf /usr/local/bin/dispenser

# Remove the dispenser user and its home directory
userdel -r dispenser || true
rm -rf /opt/dispenser


%description

%files
%dir "/opt/dispenser"
"/usr/lib/systemd/system/dispenser.service"
"/usr/local/bin/dispenser"
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ StartLimitIntervalSec=0
Type=simple
Restart=always
RestartSec=1
User=compose-watcher
User=dispenser
Environment="RUST_LOG=info"
ExecStart=/usr/local/bin/compose-watcher --config /opt/compose-watcher/compose-watcher.toml
ExecStart=/usr/local/bin/dispenser --config /opt/dispenser/dispenser.toml
ExecReload=/bin/kill -HUP $MAINPID
WorkingDirectory=/opt/compose-watcher
WorkingDirectory=/opt/dispenser

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use clap::Parser;
#[command(version, about, long_about = None)]
pub struct Args {
/// Path to the config file.
#[arg(short, long, default_value = "compose-watcher.toml")]
#[arg(short, long, default_value = "dispenser.toml")]
pub config: PathBuf,
}

Expand Down
2 changes: 0 additions & 2 deletions src/login.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// cat ~/my_password.txt | docker login --username foo --password-stdin

use base64::Engine;
use std::collections::HashMap;
use std::env;
Expand Down

0 comments on commit 79fdec2

Please sign in to comment.