diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..6f2963f107d008fba6876708f2799c01df712cb3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +*.bak +docker-compose.yml +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f23813b85d968419c118207ff830193627f85c3c --- /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 0000000000000000000000000000000000000000..9f7b626de513e359570b0c8055fafe919d223c42 --- /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