From 9ce2162d39f2d72358b54b1385c3abf908c434b1 Mon Sep 17 00:00:00 2001
From: Matheus Horstmann <mch15@inf.ufpr.br>
Date: Tue, 26 Feb 2019 11:56:26 -0300
Subject: [PATCH] Issue #3: Add dockerfile

Signed-off-by: Matheus Horstmann <mch15@inf.ufpr.br>
---
 .dockerignore        |  3 +++
 Dockerfile           | 34 ++++++++++++++++++++++++++++++++++
 docker-entrypoint.sh | 24 ++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 .dockerignore
 create mode 100644 Dockerfile
 create mode 100644 docker-entrypoint.sh

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..6f2963f
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+*.bak
+docker-compose.yml
+.env
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..f23813b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,34 @@
+FROM debian:stretch
+LABEL maintainer="horstmannmat <mch15@inf.ufpr.br>"
+
+ENV DEBIAN_FRONTEND noninteractive
+ENV LANG C.UTF-8
+
+# Install dependencies:
+# - build-essential: To ensure certain gems can be compiled
+# - nodejs: Compile assets
+# - libpq-dev: Communicate with postgres through the postgres gem
+# - wget curl and gnupg is used to get newest postgres client
+# - software-properties-common to use the command lsb_release
+#- Get newest postgres client
+
+RUN apt-get -y -qqq  update && apt-get -qqq install -y apt-utils libpq-dev wget gnupg software-properties-common curl build-essential --fix-missing --no-install-recommends && \
+echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
+wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
+apt-get -y update -qq && apt-get install -y -qq postgresql-client-10 git vim
+
+# Set an environment variable to store where the app is installed to inside of the Docker image.
+RUN useradd -ms /bin/bash agent
+
+
+USER agent
+ENV WORKSPACE /home/agent/agent-colector-database
+RUN mkdir -p $WORKSPACE
+WORKDIR $WORKSPACE
+
+COPY  --chown=agent:agent . .
+
+ENTRYPOINT ["/home/agent/agent-colector-database/docker-entrypoint.sh"]
+
+
+CMD ["/bin/bash"]
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100644
index 0000000..9f7b626
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+sleep 15
+export PGPASSWORD=${POSTGRES_PASSWORD}
+connectcommand() {
+PGPASSWORD=${POSTGRES_PASSWORD} psql -h ${POSTGRES_HOST}\
+        -U ${POSTGRES_USER} -c "\d"
+}
+
+connectcommand
+while [ $? -ne 0 ]
+do
+    echo "Waiting postgres start"
+    sleep 2
+    connectcommand
+done
+
+# /home/formdatabase/form-creator-database/psql-manager/manager.sh drop
+/home/formdatabase/form-creator-database/psql-manager/manager.sh create /home/formdatabase/form-creator-database/workspace
+/home/formdatabase/form-creator-database/psql-manager/manager.sh  fixture /home/formdatabase/form-creator-database/workspace
+
+while true
+do
+    sleep 2
+done
-- 
GitLab