From 5df19e50516d6edf066b043ba3afdd4ab81030a8 Mon Sep 17 00:00:00 2001 From: ILoveYaToo Date: Wed, 20 May 2020 00:14:49 -0400 Subject: [PATCH] test to see if this fixes the issue --- alpine/Dockerfile | 3 ++- alpine/config/.gitkeep | 0 alpine/docker-compose.yml | 6 ++++-- alpine/src/create-user.sh | 11 +++++++++++ alpine/src/docker-entrypoint.sh | 18 ++++++++++-------- ubuntu/Dockerfile | 3 ++- ubuntu/config/.gitkeep | 0 ubuntu/docker-compose.yml | 8 ++++++-- ubuntu/src/docker-entrypoint.sh | 18 ++++++++++-------- 9 files changed, 45 insertions(+), 22 deletions(-) delete mode 100644 alpine/config/.gitkeep create mode 100755 alpine/src/create-user.sh delete mode 100644 ubuntu/config/.gitkeep diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 8c4973e..e02bf2f 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -5,7 +5,7 @@ ENV DOCKERIZE_VERSION v0.6.1 RUN wget https://github.com/wrouesnel/p2cli/releases/download/r5/p2 -O /usr/local/bin/p2 \ && chmod +x /usr/local/bin/p2 -RUN apk --no-cache add nodejs mariadb-client git bash libcap build-base mariadb-dev tzdata mariadb-connector-c openssl \ +RUN apk --no-cache add nodejs mariadb-client git bash libcap build-base mariadb-dev tzdata mariadb-connector-c openssl expect\ && git clone https://github.com/atech/postal.git /opt/postal \ && rm -rf /var/lib/apt/lists/* \ && gem install bundler \ @@ -28,6 +28,7 @@ RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/ruby ## Stick in required files ADD src/docker-entrypoint.sh /docker-entrypoint.sh +ADD src/create-user.sh /create-user.sh ADD src/templates /templates ## Expose diff --git a/alpine/config/.gitkeep b/alpine/config/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/alpine/docker-compose.yml b/alpine/docker-compose.yml index 6be8e35..7178b4c 100644 --- a/alpine/docker-compose.yml +++ b/alpine/docker-compose.yml @@ -1,7 +1,8 @@ version: "3" services: postal: - image: catdeployed/postal:alpine + #image: catdeployed/postal:alpine + build: . container_name: postal command: run ports: @@ -10,7 +11,7 @@ services: - "mysql" - "rabbitmq" volumes: - - ./config/postal.yml:/opt/postal/config/postal.yml + - persistent_assets:/storage - static_assets:/opt/postal/public - postal_assets:/opt/postal/public/assets - ./src/templates/:/templates @@ -61,3 +62,4 @@ volumes: static_assets: postal_assets: mysql_data: + persistent_assets: diff --git a/alpine/src/create-user.sh b/alpine/src/create-user.sh new file mode 100755 index 0000000..5b2219a --- /dev/null +++ b/alpine/src/create-user.sh @@ -0,0 +1,11 @@ +#!/usr/bin/expect +eval spawn /opt/postal/bin/postal make-user +expect "E-Mail" +send "$env(POSTAL_EMAIL)\n" +expect "First Name" +send "$env(POSTAL_FNAME)\n" +expect "Last Name" +send "$env(POSTAL_LNAME)\n" +expect "Password" +send "$env(POSTAL_PASSWORD)\n" +interact diff --git a/alpine/src/docker-entrypoint.sh b/alpine/src/docker-entrypoint.sh index d651426..648c9a8 100755 --- a/alpine/src/docker-entrypoint.sh +++ b/alpine/src/docker-entrypoint.sh @@ -4,6 +4,11 @@ rm -rf /opt/postal/tmp/pids/* rm -rf /tmp/postal +## Check if existing config +if [ -f /storage/postal.yml ]; then + cp /storage/postal.yml /opt/postal/config/postal.yml +fi + ## Generate config if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then ## Build Jinja2 Template @@ -15,18 +20,15 @@ if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal. /opt/postal/bin/postal initialize-config ## Wait for MySQL and RabbitMQ to start up echo "== Waiting for MySQL and RabbitMQ to start up ==" - dockerize -wait tcp://mysql:3306 -wait http://rabbitmq:5672/api/aliveness-test + dockerize -timeout 60m -wait tcp://mysql:3306 -wait tcp://rabbitmq:5672 /opt/postal/bin/postal initialize - /opt/postal/bin/postal make-user <<-EOF -$POSTAL_EMAIL -$POSTAL_FNAME -$POSTAL_LNAME -$POSTAL_PASSWORD -EOF + /create-user.sh + ## Copy over config to persistent storage + cp /opt/postal/config/postal.yml /storage/postal.yml else ## Wait for MySQL and RabbitMQ to start up echo "== Waiting for MySQL and RabbitMQ to start up ==" - dockerize -wait tcp://mysql:3306 -wait http://rabbitmq:5672/api/aliveness-test + dockerize -timeout 60m -wait tcp://mysql:3306 -wait tcp://rabbitmq:5672 fi ## Start Postal /opt/postal/bin/postal "$@" diff --git a/ubuntu/Dockerfile b/ubuntu/Dockerfile index 37a63dd..feada40 100644 --- a/ubuntu/Dockerfile +++ b/ubuntu/Dockerfile @@ -9,7 +9,7 @@ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ && apt-get install -y nodejs RUN apt-get -y update \ - && apt-get -y install --no-install-recommends nodejs mariadb-client git-core libcap2-bin wget \ + && apt-get -y install --no-install-recommends nodejs mariadb-client git-core libcap2-bin wget expect\ && git clone https://github.com/atech/postal.git /opt/postal \ && rm -rf /var/lib/apt/lists/* \ && gem install bundler \ @@ -32,6 +32,7 @@ RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/ruby ## Stick in required files ADD src/docker-entrypoint.sh /docker-entrypoint.sh +ADD src/create-user.sh /create-user.sh ADD src/templates /templates ## Expose diff --git a/ubuntu/config/.gitkeep b/ubuntu/config/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ubuntu/docker-compose.yml b/ubuntu/docker-compose.yml index c15974b..1b94645 100644 --- a/ubuntu/docker-compose.yml +++ b/ubuntu/docker-compose.yml @@ -1,16 +1,19 @@ version: "3" services: postal: - image: catdeployed/postal:ubuntu + #image: catdeployed/postal:ubuntu + build: . container_name: postal command: run + tty: true ports: - 127.0.0.1:25:25 depends_on: - "mysql" - "rabbitmq" volumes: - - ./config/postal.yml:/opt/postal/config/postal.yml +# - ./config/postal.yml:/opt/postal/config/postal.yml + - persistent_assets:/storage - static_assets:/opt/postal/public - postal_assets:/opt/postal/public/assets - ./src/templates/:/templates @@ -58,6 +61,7 @@ services: - static_assets:/opt/postal/public:ro - postal_assets:/opt/postal/public/assets:ro volumes: + persistent_assets: static_assets: postal_assets: mysql_data: diff --git a/ubuntu/src/docker-entrypoint.sh b/ubuntu/src/docker-entrypoint.sh index d651426..648c9a8 100755 --- a/ubuntu/src/docker-entrypoint.sh +++ b/ubuntu/src/docker-entrypoint.sh @@ -4,6 +4,11 @@ rm -rf /opt/postal/tmp/pids/* rm -rf /tmp/postal +## Check if existing config +if [ -f /storage/postal.yml ]; then + cp /storage/postal.yml /opt/postal/config/postal.yml +fi + ## Generate config if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then ## Build Jinja2 Template @@ -15,18 +20,15 @@ if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal. /opt/postal/bin/postal initialize-config ## Wait for MySQL and RabbitMQ to start up echo "== Waiting for MySQL and RabbitMQ to start up ==" - dockerize -wait tcp://mysql:3306 -wait http://rabbitmq:5672/api/aliveness-test + dockerize -timeout 60m -wait tcp://mysql:3306 -wait tcp://rabbitmq:5672 /opt/postal/bin/postal initialize - /opt/postal/bin/postal make-user <<-EOF -$POSTAL_EMAIL -$POSTAL_FNAME -$POSTAL_LNAME -$POSTAL_PASSWORD -EOF + /create-user.sh + ## Copy over config to persistent storage + cp /opt/postal/config/postal.yml /storage/postal.yml else ## Wait for MySQL and RabbitMQ to start up echo "== Waiting for MySQL and RabbitMQ to start up ==" - dockerize -wait tcp://mysql:3306 -wait http://rabbitmq:5672/api/aliveness-test + dockerize -timeout 60m -wait tcp://mysql:3306 -wait tcp://rabbitmq:5672 fi ## Start Postal /opt/postal/bin/postal "$@"