Import docker-gc-build branch
authorSofian Brabez <sofian.brabez@gonitro.com>
Mon, 26 Nov 2018 10:45:16 +0000 (10:45 +0000)
committerSofian Brabez <sofian.brabez@gonitro.com>
Mon, 26 Nov 2018 11:00:25 +0000 (11:00 +0000)
From [docker-gc-build](/Nitro/docker-gc/tree/sbrabez/docker-gc-build)
branch which was existing in the Nitro's docker-gc fork. This will help
us to have a better tracking and simplify the release process of new
docker-gc version in our apt repository.

Dockerfile [new file with mode: 0644]
release.sh [new file with mode: 0755]

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..4f47ea1
--- /dev/null
@@ -0,0 +1,27 @@
+FROM ubuntu:xenial
+
+LABEL description="Docker image for building docker-gc debian package" \
+      maintainer="infra-guild@gonitro.com" \
+      repository="https://github.com/Nitro/docker-gc"
+
+ARG VERSION
+ARG AWS_ACCESS_KEY_ID
+ARG AWS_SECRET_ACCESS_KEY
+
+ADD . /tmp
+
+WORKDIR /tmp
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update && apt install -y \
+    git \
+    devscripts \
+    debhelper \
+    curl \
+    build-essential \
+    dh-make
+
+RUN DEBEMAIL="Infrastructure Guild <infra-guild@gonitro.com>" dch "Nitro build." \
+    --newversion "${VERSION}" \
+    --no-auto-nmu
+
+RUN debuild --no-lintian -us -uc -b
\ No newline at end of file
diff --git a/release.sh b/release.sh
new file mode 100755 (executable)
index 0000000..36f01f3
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+set -e
+
+DRY_RUN=' '
+
+[ ! -f `which gpg` ] && {
+    echo 2>&1 "You need to install gnupg: brew install gnupg"
+    exit 2
+}
+
+[ ! -f `which deb-s3` ] && {
+    echo 2>&1 "You need to install deb-s3: gem install deb-s3"
+    exit 2
+}
+
+COMMIT=`git rev-parse --short HEAD`
+VERSION="2:`cat version.txt`~${COMMIT}"
+TAG="gonitro/docker-gc-build:${COMMIT}"
+AWS_REGION=us-west-2
+BUCKET=nitro-apt-repo
+NITRO_GPG_KEY=C5075270
+
+$DRY_RUN docker build \
+    -t ${TAG} \
+    --build-arg VERSION=${VERSION} \
+    --build-arg AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
+    --build-arg AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
+    -f ./Dockerfile .
+
+$DRY_RUN docker run -v /tmp/:/tmp ${TAG} /bin/bash -c 'cp /docker-gc*.deb /tmp'
+
+package=`ls /tmp/*.deb`
+echo Debian Package generated into ${package}
+
+$DRY_RUN deb-s3 upload \
+    --access-key-id=${AWS_ACCESS_KEY_ID} \
+    --secret-access-key=${AWS_SECRET_ACCESS_KEY} \
+    --s3-region=${AWS_REGION} \
+    --bucket=${BUCKET} \
+    --sign=${NITRO_GPG_KEY} ${package} || exit 1
+echo Successfully uploaded package into ${BUCKET}
+
+exit 0