diff --git a/README.md b/README.md index 2f3598b..513b3c2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,33 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/volkerraschek/createrepo)](https://hub.docker.com/r/volkerraschek/createrepo) This project contains all sources to build the container image -`docker.io/volkerraschek/createrepo`. The primary goal of this project is to package -the binary `createrepo` as container image to provide the functionally for CI/CD -workflows or for systems which does contains the binary. +`docker.io/volkerraschek/createrepo` and the shell script `createrepo.sh`. + +The primary goal of this project is to package the binary `createrepo` as +container image to provide the functionally for CI/CD workflows or for systems +which does contains the binary. + +## createrepo.sh + +The shell script `createrepo.sh` is a wrapper for the binary `createrepo`, which +is not available depending on the distribution. It starts the container image +`docker.io/volkerraschek/createrepo` in the background to call the binary. For +this reason, a container runtime like `docker` or `podman` is necessary. + +### Installation + +The script can be installed via the following command: + +```bash +curl https://git.cryptic.systems/volker.raschek/createrepo-docker/raw/branch/master/createrepo.sh --output - | sudo tee /usr/local/bin/createrepo.sh && sudo chmod +x /usr/local/bin/createrepo.sh +``` + +### Usage + +The script forwards all arguments directly to the binary running inside the +container. For this reason, all arguments from the original binary can be used. + +```bash +createrepo.sh --update . # Update local repository +createrepo.sh --update /var/www/my-repo # Update repository based on specific path +``` diff --git a/createrepo.sh b/createrepo.sh new file mode 100644 index 0000000..933920b --- /dev/null +++ b/createrepo.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +CONTAINER_RUNTIME=$(which docker) +CREATEREPO_IMAGE_VERSION=0.17.2 + +CUSTOM_UID=$(getent passwd ${USER} | cut -d ':' -f 3) +CUSTOM_GID=$(getent passwd ${USER} | cut -d ':' -f 4) + +${CONTAINER_RUNTIME} run \ + --rm \ + --volume ${PWD}:${PWD} \ + --workdir ${PWD} \ + --user ${CUSTOM_UID}:${CUSTOM_GID} \ + docker.io/volkerraschek/createrepo:${CREATEREPO_IMAGE_VERSION} ${@}