From 1330617443c1a1a2ccf2aa9bab38e12ac568cb80 Mon Sep 17 00:00:00 2001 From: CatDeployed Date: Fri, 3 Aug 2018 06:02:42 +0200 Subject: [PATCH 1/8] update README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 928f612..7d35588 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,11 @@ Port mappings may change (as they have in the past). If SMTP/HTTP(s) is not work ### Anti-Spam / Antivirus The initial design for the container was to be simple, minimal, and customizable, so Spamassassin and ClamAV are not included by default. Feel free to fork and add to the Dockerfile (though you must set docker-compose.yml to build from Dockerfile and not pull an image), or add them by linking additional containers. + +### Updates + +- v2.0.0 + * Update to more reliable version of YAML management system + * Split into ubuntu and alpine images +- v1.0.0 + * Initial Release From ce3aad84a8526fbc8e806d0f00c84075b2936d4f Mon Sep 17 00:00:00 2001 From: CatDeployed Date: Fri, 3 Aug 2018 06:06:28 +0200 Subject: [PATCH 2/8] update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7d35588..2f2f5be 100644 --- a/README.md +++ b/README.md @@ -42,5 +42,6 @@ The initial design for the container was to be simple, minimal, and customizable - v2.0.0 * Update to more reliable version of YAML management system * Split into ubuntu and alpine images + * Moved to CircleCI for more advanced building - v1.0.0 * Initial Release From 129fa8be448ec6e1049bff712efa60fb110bed0a Mon Sep 17 00:00:00 2001 From: CatDeployed Date: Fri, 3 Aug 2018 06:16:16 +0200 Subject: [PATCH 3/8] update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f2f5be..4303b71 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ #### Alpine Linux Container (Default) -![](https://images.microbadger.com/badges/image/catdeployed/postal:alpine.svg) ![](https://img.shields.io/microbadger/layers/catdeployed/postal/alpine.svg) +[![](https://images.microbadger.com/badges/image/catdeployed/postal:alpine.svg)](https://hub.docker.com/r/catdeployed/postal/) [![](https://img.shields.io/microbadger/layers/catdeployed/postal/alpine.svg)](https://hub.docker.com/r/catdeployed/postal/) For this container, use the 'alpine' folder. #### Ubuntu Linux Container -![](https://images.microbadger.com/badges/image/catdeployed/postal:ubuntu.svg) ![](https://img.shields.io/microbadger/layers/catdeployed/postal/ubuntu.svg) +[![](https://images.microbadger.com/badges/image/catdeployed/postal:ubuntu.svg)](https://hub.docker.com/r/catdeployed/postal/) [![](https://img.shields.io/microbadger/layers/catdeployed/postal/ubuntu.svg)](https://hub.docker.com/r/catdeployed/postal/) -For this container, use the 'ubuntu' folder +For this container, use the 'ubuntu' folder. ### Instructions Change configuration in docker-compose.yml to update passwords for MySQL/RabbitMQ. Note that both passwords in the `postal` service, `mysql` service and `rabbitmq` service have to be changed to the same values. From 739d590fa4388718eba7523056737cab4d8994fb Mon Sep 17 00:00:00 2001 From: CatDeployed Date: Fri, 3 Aug 2018 06:31:01 +0200 Subject: [PATCH 4/8] update build tasks --- .circleci/config.yml | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9e7a76a..0258595 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,6 +59,39 @@ jobs: - run: name: Push Latest Container to Docker Hub command: docker push catdeployed/postal:latest + deploy-dev: + machine: true + working_directory: ~/repo/ubuntu + steps: + - attach_workspace: + at: /tmp/workspace + - run: + name: Load Alpine Image + command: docker load --input /tmp/workspace/postal_alpine.tar + - run: + name: Load Ubuntu Image + command: docker load --input /tmp/workspace/postal_ubuntu.tar + - run: + name: Rename Alpine Image Tag + command: docker tag catdeployed/postal:alpine catdeployed/postal:alpine-dev + - run: + name: Rename Ubuntu Image Tag + command: docker tag catdeployed/ubuntu:ubuntu catdeployed/postal:ubuntu-dev + - run: + name: Tag alpine image as latest + command: docker tag catdeployed/postal:alpine catdeployed/postal:latest-dev + - run: + name: Login to Docker Hub + command: docker login -u $DOCKER_USER -p $DOCKER_PASS + - run: + name: Push Ubuntu Container to Docker Hub + command: docker push catdeployed/postal:ubuntu-dev + - run: + name: Push Alpine Container to Docker Hub + command: docker push catdeployed/postal:alpine-dev + - run: + name: Push Latest Container to Docker Hub + command: docker push catdeployed/postal:latest-dev workflows: version: 2 nightly: @@ -69,7 +102,6 @@ workflows: branches: only: - master - - dev jobs: - build-alpine - build-ubuntu @@ -81,7 +113,6 @@ workflows: branches: only: - master - - dev commit: jobs: - build-alpine @@ -94,6 +125,13 @@ workflows: branches: only: - master + - deploy-dev: + requires: + - build-alpine + - build-ubuntu + filters: + branches: + only: - dev notify: webhooks: From 480435be92d1aa5a0cd1fab87632146ebc8a0f97 Mon Sep 17 00:00:00 2001 From: CatDeployed Date: Fri, 3 Aug 2018 06:34:58 +0200 Subject: [PATCH 5/8] update circleci --- .circleci/config.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0258595..f21f26f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,12 +6,12 @@ jobs: steps: - checkout: path: ~/repo - - run: + - run: name: Build Postal Docker Container command: docker build -t catdeployed/postal:latest -t catdeployed/postal:alpine . - run: name: Export Container - command: mkdir workspace && cd workspace && docker save --output postal_alpine.tar catdeployed/postal:alpine + command: mkdir workspace && cd workspace && docker save --output postal_alpine.tar catdeployed/postal:alpine - persist_to_workspace: root: workspace paths: @@ -111,7 +111,7 @@ workflows: - build-ubuntu filters: branches: - only: + only: - master commit: jobs: @@ -133,6 +133,3 @@ workflows: branches: only: - dev -notify: - webhooks: - - url: https://hooks.microbadger.com/images/catdeployed/postal/K0vCLtQnFFKukT-LuAEBmGD0cHs= From dc8de3b2cd7bf905b7e941e39c1fa0e93d1c2d23 Mon Sep 17 00:00:00 2001 From: CatDeployed Date: Fri, 3 Aug 2018 06:37:23 +0200 Subject: [PATCH 6/8] update config --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f21f26f..a6ba1bb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -133,3 +133,6 @@ workflows: branches: only: - dev +notify: + webhooks: + - url: https://hooks.microbadger.com/images/catdeployed/postal/K0vCLtQnFFKukT-LuAEBmGD0cHs= From 0d01b1cee69f5fd6ebb7cd16b62d303524583864 Mon Sep 17 00:00:00 2001 From: Denis Denisov Date: Mon, 27 Aug 2018 03:49:44 +0300 Subject: [PATCH 7/8] ruby v2.6-rc, j2cli drop-in replacement by p2cli * j2cli replaced by p2cli (https://github.com/wrouesnel/p2cli). - Python is removed, not needed. * Ruby 2.6-rc (Alpine & Ubuntu). --- alpine/Dockerfile | 9 ++++++--- alpine/src/docker-entrypoint.sh | 2 +- alpine/src/nginx.conf | 2 +- ubuntu/Dockerfile | 12 +++++++++--- ubuntu/src/docker-entrypoint.sh | 2 +- ubuntu/src/nginx.conf | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 9989f6a..2970941 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -1,7 +1,9 @@ -FROM ruby:2.5-alpine +FROM ruby:2.6-rc-alpine -RUN apk --no-cache add nodejs mariadb-client git bash python2 libcap py-setuptools py-pip build-base mariadb-dev tzdata mariadb-client-libs \ - && pip install j2cli \ +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-client-libs \ && git clone https://github.com/atech/postal.git /opt/postal \ && rm -rf /var/lib/apt/lists/* \ && gem install bundler \ @@ -25,4 +27,5 @@ ADD src/templates /templates EXPOSE 5000 ## Startup +# ENV RUBYOPT --jit ENTRYPOINT ["/bin/bash", "-c", "/docker-entrypoint.sh ${*}", "--"] diff --git a/alpine/src/docker-entrypoint.sh b/alpine/src/docker-entrypoint.sh index 3a82aca..cbeeb60 100755 --- a/alpine/src/docker-entrypoint.sh +++ b/alpine/src/docker-entrypoint.sh @@ -3,7 +3,7 @@ ## Generate config if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then ## Build Jinja2 Template - j2 /templates/postal.example.yml.j2 > /opt/postal/config/postal.example.yml + p2 -t /templates/postal.example.yml.j2 -o /opt/postal/config/postal.example.yml ## Add in secret key building echo "rails:" >> /opt/postal/config/postal.example.yml echo " secret_key: {{secretkey}}" >> /opt/postal/config/postal.example.yml diff --git a/alpine/src/nginx.conf b/alpine/src/nginx.conf index 216a801..0a92b43 100644 --- a/alpine/src/nginx.conf +++ b/alpine/src/nginx.conf @@ -9,7 +9,7 @@ server { } location /assets { - add_header Cache-Control max-age=3600; + add_header Cache-Control "public,max-age=3600,immutable"; } location @puma { diff --git a/ubuntu/Dockerfile b/ubuntu/Dockerfile index f0b97ec..bf38f2c 100644 --- a/ubuntu/Dockerfile +++ b/ubuntu/Dockerfile @@ -1,8 +1,13 @@ -FROM ruby:2.4 +FROM ruby:2.6-rc + +RUN curl -L https://github.com/wrouesnel/p2cli/releases/download/r5/p2 -o /usr/local/bin/p2 \ + && chmod +x /usr/local/bin/p2 + +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 mysql-client git-core python-minimal python-pip python-dev libcap2-bin python-setuptools \ - && pip install j2cli \ + && apt-get -y install --no-install-recommends nodejs mysql-client git-core libcap2-bin \ && git clone https://github.com/atech/postal.git /opt/postal \ && rm -rf /var/lib/apt/lists/* \ && gem install bundler \ @@ -26,4 +31,5 @@ ADD src/templates /templates EXPOSE 5000 ## Startup +# ENV RUBYOPT --jit ENTRYPOINT ["/bin/bash", "-c", "/docker-entrypoint.sh ${*}", "--"] diff --git a/ubuntu/src/docker-entrypoint.sh b/ubuntu/src/docker-entrypoint.sh index 3a82aca..cbeeb60 100755 --- a/ubuntu/src/docker-entrypoint.sh +++ b/ubuntu/src/docker-entrypoint.sh @@ -3,7 +3,7 @@ ## Generate config if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then ## Build Jinja2 Template - j2 /templates/postal.example.yml.j2 > /opt/postal/config/postal.example.yml + p2 -t /templates/postal.example.yml.j2 -o /opt/postal/config/postal.example.yml ## Add in secret key building echo "rails:" >> /opt/postal/config/postal.example.yml echo " secret_key: {{secretkey}}" >> /opt/postal/config/postal.example.yml diff --git a/ubuntu/src/nginx.conf b/ubuntu/src/nginx.conf index 216a801..0a92b43 100644 --- a/ubuntu/src/nginx.conf +++ b/ubuntu/src/nginx.conf @@ -9,7 +9,7 @@ server { } location /assets { - add_header Cache-Control max-age=3600; + add_header Cache-Control "public,max-age=3600,immutable"; } location @puma { From 9e66873bd8cc1439346f3d53cf4253123f5a9216 Mon Sep 17 00:00:00 2001 From: Denis Denisov Date: Tue, 28 Aug 2018 12:49:58 +0300 Subject: [PATCH 8/8] Support prepacked assets/*.gz Do not consume CPU on-the-fly GZip compression for already prepared files. --- alpine/src/nginx.conf | 6 ++---- ubuntu/src/nginx.conf | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/alpine/src/nginx.conf b/alpine/src/nginx.conf index 0a92b43..29f91ce 100644 --- a/alpine/src/nginx.conf +++ b/alpine/src/nginx.conf @@ -1,17 +1,15 @@ server { listen 80; - root /opt/postal/public; - + gzip_static on; + gzip_proxied any; location / { client_max_body_size 50M; try_files $uri $uri/index.html $uri.html @puma; } - location /assets { add_header Cache-Control "public,max-age=3600,immutable"; } - location @puma { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; diff --git a/ubuntu/src/nginx.conf b/ubuntu/src/nginx.conf index 0a92b43..29f91ce 100644 --- a/ubuntu/src/nginx.conf +++ b/ubuntu/src/nginx.conf @@ -1,17 +1,15 @@ server { listen 80; - root /opt/postal/public; - + gzip_static on; + gzip_proxied any; location / { client_max_body_size 50M; try_files $uri $uri/index.html $uri.html @puma; } - location /assets { add_header Cache-Control "public,max-age=3600,immutable"; } - location @puma { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host;