From 7223f160402088ac19a8526ab3c35a782e68faaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radoslav=20Bod=C3=B3?= <bodik@cesnet.cz>
Date: Mon, 15 Apr 2024 18:15:21 +0200
Subject: [PATCH] general: add basic docker support
---
.dockerignore | 1 +
Dockerfile | 11 +++++++++++
Makefile | 6 ++++++
scripts/docker.sh | 39 +++++++++++++++++++++++++++++++++++++++
4 files changed, 57 insertions(+)
create mode 120000 .dockerignore
create mode 100644 Dockerfile
create mode 100755 scripts/docker.sh
diff --git a/.dockerignore b/.dockerignore
new file mode 120000
index 0000000..3e4e48b
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+.gitignore
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..be935c6
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,11 @@
+FROM debian:bookworm-slim
+
+RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
+ make \
+ python3
+
+WORKDIR /opt/rwm
+COPY rwm.py Makefile ./
+RUN make install
+
+ENTRYPOINT ["/opt/rwm/rwm.py"]
diff --git a/Makefile b/Makefile
index 89da0d0..69ca3f9 100644
--- a/Makefile
+++ b/Makefile
@@ -50,3 +50,9 @@ microceph: microceph-cleanup microceph-service
runner:
apt-get install -y ansible
ansible-playbook scripts/playbook_gitlab_runner.yml
+
+docker-build:
+ sh scripts/docker.sh build
+
+docker-push:
+ sh scripts/docker.sh push
diff --git a/scripts/docker.sh b/scripts/docker.sh
new file mode 100755
index 0000000..e3dfdb9
--- /dev/null
+++ b/scripts/docker.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# release helper
+
+REGISTRY_URL="gitlab-registry.cesnet.cz"
+IMAGE_NAME="radoslav_bodo/rwm"
+
+BRANCH=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
+if [ -z "$BRANCH" ]; then
+ echo "Error: Unable to determine current branch."
+ exit 1
+fi
+
+case "$1" in
+ login)
+ docker login "$REGISTRY_URL"
+ ;;
+
+ build)
+ docker build -t "${REGISTRY_URL}/${IMAGE_NAME}:${BRANCH}" .
+ ;;
+
+ push)
+ docker push "${REGISTRY_URL}/${IMAGE_NAME}:${BRANCH}"
+ ;;
+
+ pull)
+ docker image pull "${REGISTRY_URL}/${IMAGE_NAME}:${BRANCH}"
+ ;;
+
+ run)
+ shift
+ docker run --rm -v "$(pwd)/rwm.conf:/opt/rwm/rwm.conf" -it "${REGISTRY_URL}/${IMAGE_NAME}:${BRANCH}" "$@"
+ ;;
+
+ *)
+ echo "invalid command"
+ exit 1
+ ;;
+esac
\ No newline at end of file
--
GitLab