-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'chore: Adds infrastructure for building RPM and D…
…EB packages' (#3) from andres/compose-watcher:T2 into main Reviewed-on: https://secure.ixpantia.com/imasd/dispenser/pulls/3
- Loading branch information
Showing
16 changed files
with
241 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
/target | ||
/rpmbuild | ||
.env | ||
deb/usr/local/bin/dispenser | ||
rpm/usr/local/bin/dispenser | ||
*.deb | ||
*.rpm |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "contpose" | ||
name = "dispenser" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT" | ||
|
This file contains 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,27 @@ | ||
.PHONY: build-deb build-rpm | ||
|
||
WORK_DIR=$(shell pwd) | ||
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" | ||
|
||
$(USR_BIN_RPM): $(TARGET_BIN) | ||
mkdir -p deb/usr/local/bin/ | ||
mv $(TARGET_BIN) $(USR_BIN_RPM) | ||
|
||
$(USR_BIN_DEB): $(TARGET_BIN) | ||
mkdir -p deb/usr/local/bin/ | ||
mv $(TARGET_BIN) $(USR_BIN_DEB) | ||
|
||
build-deb: $(USR_BIN_DEB) | ||
dpkg-deb --build deb | ||
mv deb.deb dispenser.deb | ||
|
||
build-rpm: $(USR_BIN_RPM) | ||
cp -r rpm/ rpmbuild | ||
mkdir -p rpmbuild/opt/dispenser | ||
rpmbuild --target=x86_64 --buildroot $(WORK_DIR)/rpmbuild \ | ||
-bb rpmbuild/dispenser.spec |
This file contains 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 |
---|---|---|
@@ -1,13 +1,44 @@ | ||
# Contpose | ||
|
||
I am not very good at naming things. This is the convination of Continuous and | ||
Compose. | ||
# Dispenser | ||
|
||
This tool manages Docker Compose instances by constantly looking for new | ||
versions of images to deploying seemlessly. | ||
|
||
Contpose 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 | ||
|
||
### RPM (RHEL) | ||
|
||
To build rpm make sure you have the following installed: | ||
|
||
- `cargo`: Rust package manager and build tool | ||
- `rustc`: Rust compiler | ||
- `make`: Run make files | ||
- `rpmbuild`: Tool to build RPMs | ||
|
||
Once these dependencies are installed run: | ||
|
||
``` | ||
make build-rpm | ||
``` | ||
|
||
|
||
This should create a file called roughly `../dispenser-$VERSION.x86_64.rpm`. | ||
|
||
### Deb (Debian & Ubuntu) | ||
|
||
To build deb make sure you have the following installed: | ||
|
||
- `cargo`: Rust package manager and build tool | ||
- `rustc`: Rust compiler | ||
- `make`: Run make files | ||
- `dpkg-dev`: Tool to build DEB files | ||
|
||
Once these dependencies are installed run: | ||
|
||
``` | ||
make build-deb | ||
``` | ||
|
||
## Installing | ||
This should create a file called roughly `./dispenser.deb`. | ||
|
||
TODO |
This file contains 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,6 @@ | ||
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, gnupg2, pass |
Empty file.
This file contains 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,23 @@ | ||
#!/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 | ||
if [ "$1" = "configure" ]; then | ||
systemctl daemon-reload || true | ||
systemctl enable dispenser.service || true | ||
systemctl start dispenser.service || true | ||
fi |
This file contains 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,15 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ "$1" = "purge" ]; then | ||
systemctl daemon-reload || true | ||
rm -f /lib/systemd/system/dispenser.service | ||
fi | ||
|
||
rm -rf /usr/local/bin/dispenser | ||
|
||
if [ "$1" = "purge" ]; then | ||
# Remove the dispenser user and its home directory | ||
userdel -r dispenser || true | ||
rm -rf /opt/dispenser | ||
fi |
This file contains 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,7 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ "$1" = "remove" ]; then | ||
systemctl stop dispenser.service || true | ||
systemctl disable dispenser.service || true | ||
fi |
This file contains 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,9 @@ | ||
#!/usr/bin/make -f | ||
|
||
%: | ||
dh $@ | ||
|
||
override_dh_installinit: | ||
dh_installinit --restart-after-upgrade | ||
dh_systemd_enable | ||
dh_systemd_start |
This file contains 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 @@ | ||
[Unit] | ||
Description=Compose Watcher | ||
After=docker.service | ||
BindsTo=docker.service | ||
StartLimitIntervalSec=0 | ||
[Service] | ||
Type=simple | ||
Restart=always | ||
RestartSec=1 | ||
User=dispenser | ||
Environment="RUST_LOG=info" | ||
ExecStart=/usr/local/bin/dispenser --config /opt/dispenser/dispenser.toml | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
WorkingDirectory=/opt/dispenser | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains 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,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" |
This file contains 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 @@ | ||
[Unit] | ||
Description=Compose Watcher | ||
After=docker.service | ||
BindsTo=docker.service | ||
StartLimitIntervalSec=0 | ||
[Service] | ||
Type=simple | ||
Restart=always | ||
RestartSec=1 | ||
User=dispenser | ||
Environment="RUST_LOG=info" | ||
ExecStart=/usr/local/bin/dispenser --config /opt/dispenser/dispenser.toml | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
WorkingDirectory=/opt/dispenser | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains 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 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