diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e132575 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM alpine:edge +MAINTAINER John Torres + +ARG VERSION +ARG GIT_COMMIT +ARG GIT_DIRTY +COPY . /workspace/ + +WORKDIR /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 --no-cache openssl-dev gcc g++ make git && \ + rm -rf /workspace + +ENTRYPOINT ["/usr/local/bin/git-crypt"] +CMD [] diff --git a/INSTALL.md b/INSTALL.md index 7fdb577..6900665 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -69,3 +69,19 @@ 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: + + IMAGE_REPO=my-fancy-repo make build-image + IMAGE_REPO=my-fancy-repo make push-image + +or + + 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