From 7a14e09dfc9f95cf3fa5e5cf9871f15443395b20 Mon Sep 17 00:00:00 2001
From: Marko Budiselic <marko.budiselic@memgraph.io>
Date: Sun, 8 Oct 2017 14:18:27 +0100
Subject: [PATCH] Add Dockerfile for csv_to_snapshot packaging.

Summary:
C++ implementation of CSV to Memgraph's snapshot file is much more efficient then
the Python implementation. It includes a huge part of the Memgraph's source
code and the code has to be compiled (which is not easy). Because of that it
has to be packaged.

Reviewers: teon.banek, mferencevic

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D854
---
 tools/.gitignore                 |  2 +-
 tools/csv_to_snapshot.dockerfile | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 tools/csv_to_snapshot.dockerfile

diff --git a/tools/.gitignore b/tools/.gitignore
index cc38133f6..1e107e2a8 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -1,2 +1,2 @@
-build
+build/
 csv_to_snapshot
diff --git a/tools/csv_to_snapshot.dockerfile b/tools/csv_to_snapshot.dockerfile
new file mode 100644
index 000000000..ceec6cc61
--- /dev/null
+++ b/tools/csv_to_snapshot.dockerfile
@@ -0,0 +1,22 @@
+FROM debian:stretch
+
+COPY csv_to_snapshot /usr/local/bin/csv_to_snapshot
+
+# Setup memgraph user and group.
+RUN groupadd -r memgraph
+RUN useradd -lrm -g memgraph memgraph
+
+# Setup intput/output directory.
+# /data is used because that's the shortest way to reference the directory.
+RUN mkdir -p /data
+RUN chown -R memgraph:memgraph /data
+
+# Change user and set working directory.
+USER memgraph:memgraph
+VOLUME /data
+WORKDIR /data
+
+ENTRYPOINT ["csv_to_snapshot"]
+# Print help and usage by default, since at least one --nodes argument is
+# required.
+CMD ["--help"]