From b51b2d70431a574ee05ed354750229bbde149f07 Mon Sep 17 00:00:00 2001 From: John Torres Date: Tue, 22 Nov 2016 00:12:39 -0500 Subject: [PATCH 1/4] build git-crypt with an alpine wrapper --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d814776 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:edge +MAINTAINER John Torres + +WORKDIR /workspace + +RUN apk add --no-cache libgcc libstdc++ libcrypto1.0 libssl1.0 openssl-dev gcc g++ make git && \ + git clone https://github.com/AGWA/git-crypt /workspace && \ + make && \ + make install PREFIX=/usr/local && \ + apk del openssl-dev gcc g++ make git && \ + rm -rf /workspace From dce26f8c7ae9d94ad7370c27bdaec5217ffbe85b Mon Sep 17 00:00:00 2001 From: John Torres Date: Tue, 22 Nov 2016 00:58:28 -0500 Subject: [PATCH 2/4] build current project instead of checking out head --- Dockerfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d814776..e132575 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,19 @@ FROM alpine:edge MAINTAINER John Torres +ARG VERSION +ARG GIT_COMMIT +ARG GIT_DIRTY +COPY . /workspace/ + WORKDIR /workspace -RUN apk add --no-cache libgcc libstdc++ libcrypto1.0 libssl1.0 openssl-dev gcc g++ make git && \ - git clone https://github.com/AGWA/git-crypt /workspace && \ +RUN echo "BUILD: $VERSION (${GIT_COMMIT}${GIT_DIRTY})" > /IMAGE_VERSION && \ + apk add --no-cache libgcc libstdc++ libcrypto1.0 libssl1.0 openssl-dev gcc g++ make git && \ make && \ make install PREFIX=/usr/local && \ - apk del openssl-dev gcc g++ make git && \ + apk del --no-cache openssl-dev gcc g++ make git && \ rm -rf /workspace + +ENTRYPOINT ["/usr/local/bin/git-crypt"] +CMD [] From d6746a5f3cbb046e9bebaa8c58036496b3aa9102 Mon Sep 17 00:00:00 2001 From: John Torres Date: Tue, 22 Nov 2016 01:07:15 -0500 Subject: [PATCH 3/4] updates to makefile and install doc to support building container image --- INSTALL.md | 19 +++++++++++++++++++ Makefile | 13 ++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 7fdb577..60c1eff 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -69,3 +69,22 @@ and does not currently create key files with restrictive permissions, making it unsuitable for use on a multi-user system. Windows support will mature in a future version of git-crypt. Bug reports and patches are most welcome! + +### Building git-crypt as a container + +To build and bundle git-crypt as a container, simply run: + + make build-image + +To build, bundle and deploy to your specific container registry, simply run: + + ```bash + IMAGE_REPO=my-fancy-repo make build-image + IMAGE_REPO=my-fancy-repo make push-image + ``` + +or + ```bash + make build-image IMAGE_REPO=my-fancy-repo + make push-image IMAGE_REPO=my-fancy-repo + ``` diff --git a/Makefile b/Makefile index dfbf9de..ae7c21b 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,10 @@ CXXFLAGS ?= -Wall -pedantic -Wno-long-long -O2 PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man +GIT_COMMIT=$(shell git rev-parse HEAD) +GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true) +VERSION=$(shell grep VERSION git-crypt.hpp | awk '{print$$NF}' | tr -d '"') +IMAGE_REPO ?= johnt337 ENABLE_MAN ?= no DOCBOOK_XSL ?= http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl @@ -88,7 +92,14 @@ install-man: build-man install -d $(DESTDIR)$(MANDIR)/man1 install -m 644 man/man1/git-crypt.1 $(DESTDIR)$(MANDIR)/man1/ +build-image: + docker build --build-arg GIT_COMMIT=$(GIT_COMMIT) --build-arg GIT_DIRTY=$(GIT_DIRTY) --build-arg VERSION=$(VERSION) -t $(IMAGE_REPO)/git-crypt:$(VERSION) . + +push-image: + docker push $(IMAGE_REPO)/git-crypt:$(VERSION) + .PHONY: all \ build build-bin build-man \ clean clean-bin clean-man \ - install install-bin install-man + install install-bin install-man \ + build-image push-image From 32effe01eefb3afb871e855e7b729d098beb451d Mon Sep 17 00:00:00 2001 From: John Torres Date: Tue, 22 Nov 2016 01:14:39 -0500 Subject: [PATCH 4/4] fixing formatting of INSTALL.md --- INSTALL.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 60c1eff..6900665 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -78,13 +78,10 @@ To build and bundle git-crypt as a container, simply run: To build, bundle and deploy to your specific container registry, simply run: - ```bash IMAGE_REPO=my-fancy-repo make build-image IMAGE_REPO=my-fancy-repo make push-image - ``` or - ```bash + make build-image IMAGE_REPO=my-fancy-repo make push-image IMAGE_REPO=my-fancy-repo - ```