From de0fe250634a1a69f442c726df8e9054d15af4ec Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 08:41:17 -0400 Subject: [PATCH 01/17] Update the encrypted Docker config to the new key --- .gitignore | 4 ++++ dockercfg.encrypted | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9dfa377bcf857..124ff230475c6 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,7 @@ bundler_stubs/* vendor/bundle/* *.db + +# Codeship Docker Plattform +codeship.aes +dockercfg diff --git a/dockercfg.encrypted b/dockercfg.encrypted index 9f63d90f44ac7..96280fa091a62 100644 --- a/dockercfg.encrypted +++ b/dockercfg.encrypted @@ -1 +1 @@ -4iE+JmvBTwm21rQEfbxEBhC6Ht6NyWbN8agi/aUQrB3A/JU3JnBBqvDXp2ryUufU75V58kJukKrNA4VmRRzmv3lGrjLMqB5j1Ljf84f80P32jShFaZOpO6JtV/OZMWpKTHosjOnwae+jny2sqeLukzh2MymN/PhkiptMzNcwB77c4N3h5IJGM7z04ffIndawvT2zUbO5k/MU6FHZSP8= \ No newline at end of file +r783vDS1vsSBe+ueW9hJGC740IL5Jf+2EkOYHrk8iYn56PHsqPbwOevBVAKvMvCX7luNYyCj8KfF0O3syON+PENtPrqRb1uILamd2nBhwnAk766o+59o5EM0/Eeh388482PbObrD1L6BENyTbdppiRyL1AYu1SuB1xvYSPJfiLcO8dqDhD5NUEVd2CgFvULASN3N3KeLRAuBMdzJrzk= \ No newline at end of file From 3b902bcdfb4af84e29bc0fbcfa65011408808d5f Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 09:19:03 -0400 Subject: [PATCH 02/17] Clean up Dockerfile * Update Ruby version to 2.3.1 * Switch Maintainer to codeship * Update and sort apt package installations, clean up afterwards * Clean up after PhantomJS installation (and only keep the binary) * Copy files in a single step and combine `bundle install` and the `gem install` commands --- Dockerfile | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6e8837cc81bd3..914a5d04dbf11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,39 @@ -FROM ruby:2.2.1 -MAINTAINER flo@codeship.com +FROM ruby:2.3.1-slim +MAINTAINER maintainers@codeship.com + +ENV \ + DEBIAN_FRONTEND=noninteractive \ + PHANTOMJS_VERSION=1.9.7 RUN \ - apt-get update -y && \ - apt-get upgrade -y && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y \ + apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ build-essential \ + bzip2 \ + git \ + libfontconfig \ + libfreetype6 \ libpq-dev \ nodejs \ - apt-utils \ - vim git wget libfreetype6 libfontconfig bzip2 time python-pip - -ENV PHANTOMJS_VERSION 1.9.7 + python-pip \ + time \ + vim \ + wget \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* \ + && pip install awscli RUN \ - mkdir -p /srv/var && \ - wget -q --no-check-certificate -O /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 https://s3.amazonaws.com/codeship.io/checkbot/archives/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 && \ - tar -xjf /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C /tmp && \ - rm -f /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 && \ - mv /tmp/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/ /srv/var/phantomjs && \ - ln -s /srv/var/phantomjs/bin/phantomjs /usr/bin/phantomjs - -RUN pip install awscli + wget --output-document /tmp/phantomjs-linux-x86_64.tar.bz2 "https://s3.amazonaws.com/codeship-packages/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2" \ + && tar -xaf /tmp/phantomjs-linux-x86_64.tar.bz2 --directory /tmp/ \ + && mv "/tmp/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64/bin/phantomjs" /usr/bin/phantomjs \ + && rm -rf /tmp/phantomjs-linux-x86_64.tar.bz2 "/tmp/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64" -RUN mkdir -p /app -WORKDIR /app -COPY Gemfile ./Gemfile -COPY Gemfile.lock ./Gemfile.lock -COPY vendor ./vendor -RUN bundle install -j24 -RUN gem install parallel_tests +COPY Gemfile Gemfile.lock vendor /app/ +RUN \ + cd /app/ \ + && bundle install --jobs 20 --retry 5 \ + && gem install parallel_tests \ WORKDIR /code From 271d7e2082f7d81a5891544687b2c91522301766 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 09:23:46 -0400 Subject: [PATCH 03/17] Update services description * Sort environment variables * Update to PostgreSQL 9.5 * Update to Redis 3.2 (Alpine based) --- codeship-services.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/codeship-services.yml b/codeship-services.yml index 58f3f2648aa7d..92d9aa7af05ab 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -1,12 +1,11 @@ app: build: - image: flomotlik/discourse dockerfile_path: Dockerfile environment: - SECRET_TOKEN: abcdefghij - REDIS_ADDRESS: redis://redis:6379 - RAILS_ENV: test DATABASE_HOST: postgresql + RAILS_ENV: test + REDIS_ADDRESS: redis://redis:6379 + SECRET_TOKEN: abcdefghij links: - postgresql - redis @@ -14,6 +13,6 @@ app: volumes: - ./:/code postgresql: - image: postgres:9.3.6 + image: postgres:9.5 redis: - image: redis:3.0.2 + image: redis:3.2-alpine From 70cf451a54f45d2189284ffed71df0aca8e0f2c7 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 09:24:52 -0400 Subject: [PATCH 04/17] Remove dockercfg It's no longer required for caching and we don't push the image during the build. --- codeship-steps.yml | 1 - dockercfg.encrypted | 1 - 2 files changed, 2 deletions(-) delete mode 100644 dockercfg.encrypted diff --git a/codeship-steps.yml b/codeship-steps.yml index 54572177a9d52..9280a3efc7652 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -1,5 +1,4 @@ - type: parallel - encrypted_dockercfg_path: dockercfg.encrypted steps: - service: app command: ./script/ci/ci.parallel spec diff --git a/dockercfg.encrypted b/dockercfg.encrypted deleted file mode 100644 index 96280fa091a62..0000000000000 --- a/dockercfg.encrypted +++ /dev/null @@ -1 +0,0 @@ -r783vDS1vsSBe+ueW9hJGC740IL5Jf+2EkOYHrk8iYn56PHsqPbwOevBVAKvMvCX7luNYyCj8KfF0O3syON+PENtPrqRb1uILamd2nBhwnAk766o+59o5EM0/Eeh388482PbObrD1L6BENyTbdppiRyL1AYu1SuB1xvYSPJfiLcO8dqDhD5NUEVd2CgFvULASN3N3KeLRAuBMdzJrzk= \ No newline at end of file From fdd43dbd22686b82ad69486b7fcd0ccb90122d2f Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 09:26:07 -0400 Subject: [PATCH 05/17] =?UTF-8?q?Fix=20a=20syntax=20error=20in=20the=20Doc?= =?UTF-8?q?kerfile=20=F0=9F=98=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 914a5d04dbf11..3935cd887c037 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,6 @@ COPY Gemfile Gemfile.lock vendor /app/ RUN \ cd /app/ \ && bundle install --jobs 20 --retry 5 \ - && gem install parallel_tests \ + && gem install parallel_tests WORKDIR /code From f12ca7895dabd46e474d9c9a20d2d06868aa6668 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 09:28:55 -0400 Subject: [PATCH 06/17] Switch wget to no verbose output mode --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3935cd887c037..98a403aec01d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ RUN \ && pip install awscli RUN \ - wget --output-document /tmp/phantomjs-linux-x86_64.tar.bz2 "https://s3.amazonaws.com/codeship-packages/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2" \ + wget --no-verbose --output-document /tmp/phantomjs-linux-x86_64.tar.bz2 "https://s3.amazonaws.com/codeship-packages/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2" \ && tar -xaf /tmp/phantomjs-linux-x86_64.tar.bz2 --directory /tmp/ \ && mv "/tmp/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64/bin/phantomjs" /usr/bin/phantomjs \ && rm -rf /tmp/phantomjs-linux-x86_64.tar.bz2 "/tmp/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64" From e7fc350219564b79a88e6cb8a423315f744dacd5 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 09:34:20 -0400 Subject: [PATCH 07/17] Name CI steps and extract service to parent step --- codeship-steps.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/codeship-steps.yml b/codeship-steps.yml index 9280a3efc7652..31dae9fd6a79c 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -1,10 +1,11 @@ - type: parallel + service: app steps: - - service: app + - name: Specs command: ./script/ci/ci.parallel spec - - service: app + - name: Plugins command: ./script/ci/ci.parallel plugin - - service: app + - name: QUnit command: ./script/ci/ci.parallel qunit - - service: app + - name: PhantomJS command: phantomjs --help From 816f5de26c0d55d34f576e81e5c5267e5cef12ab Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 10:50:30 -0400 Subject: [PATCH 08/17] Install missing packages for the rspec step --- Dockerfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Dockerfile b/Dockerfile index 98a403aec01d8..055ab473a8415 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,12 +11,19 @@ RUN \ apt-utils \ build-essential \ bzip2 \ + gifsicle \ git \ + graphicsmagick-imagemagick-compat \ + jhead \ + jpegoptim \ libfontconfig \ libfreetype6 \ + libjpeg-progs \ libpq-dev \ nodejs \ + optipng \ python-pip \ + postgresql-client-9.4 \ time \ vim \ wget \ From fd288bce7fd9817fc69edb066e65b20874a01d88 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 11:01:58 -0400 Subject: [PATCH 09/17] Install svgo and update NPM as well --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 055ab473a8415..a94316accf5d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,9 @@ RUN \ wget \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* \ - && pip install awscli + && pip install awscli \ + && npm install npm -g \ + && npm install -g svgo RUN \ wget --no-verbose --output-document /tmp/phantomjs-linux-x86_64.tar.bz2 "https://s3.amazonaws.com/codeship-packages/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2" \ From 3e4d1797c78ae42949c5fe88e3efa09d66b83737 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 11:05:46 -0400 Subject: [PATCH 10/17] Add PostgreSQL related environment variables for use with the CLI --- codeship-services.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codeship-services.yml b/codeship-services.yml index 92d9aa7af05ab..2a6ecd26b9abe 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -3,6 +3,8 @@ app: dockerfile_path: Dockerfile environment: DATABASE_HOST: postgresql + PGHOST: postgresql + PGUSER: postgres RAILS_ENV: test REDIS_ADDRESS: redis://redis:6379 SECRET_TOKEN: abcdefghij From db17e02e1a60b6ab8ca033f63fed6d9ac9e79590 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 11:23:55 -0400 Subject: [PATCH 11/17] Copy the code into the Docker image * Remove the volume that mounted the code * Adapt the Dockerfile to use /code for all steps * Update the .dockerignore file --- .dockerignore | 16 +++++++++++++++- Dockerfile | 7 +++++-- codeship-services.yml | 2 -- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 1a2d31e73d2e4..e761e03a93f2a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,16 @@ -tmp + .git +*.sublime-project +aws_machines +Brewfile +build_times +build_types +codeship-services.yml +codeship-steps* +codeship.aes +CONTRIBUTING.md +COPYRIGHT.txt +LICENSE.txt +README.md +tmp +Vagrantfile diff --git a/Dockerfile b/Dockerfile index a94316accf5d7..2a183c9929085 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,10 +39,13 @@ RUN \ && mv "/tmp/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64/bin/phantomjs" /usr/bin/phantomjs \ && rm -rf /tmp/phantomjs-linux-x86_64.tar.bz2 "/tmp/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64" -COPY Gemfile Gemfile.lock vendor /app/ +RUN mkdir /code +WORKDIR /code + +COPY Gemfile Gemfile.lock vendor ./ RUN \ cd /app/ \ && bundle install --jobs 20 --retry 5 \ && gem install parallel_tests -WORKDIR /code +COPY . ./ diff --git a/codeship-services.yml b/codeship-services.yml index 2a6ecd26b9abe..ed116cdde36fb 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -12,8 +12,6 @@ app: - postgresql - redis cached: true - volumes: - - ./:/code postgresql: image: postgres:9.5 redis: From 2967225c5cb7eac95176bc73990516365d6e63ac Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 11:31:06 -0400 Subject: [PATCH 12/17] Install NodeJS via their offical Debian repository --- Dockerfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a183c9929085..af560c75b1092 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,19 +2,27 @@ FROM ruby:2.3.1-slim MAINTAINER maintainers@codeship.com ENV \ - DEBIAN_FRONTEND=noninteractive \ - PHANTOMJS_VERSION=1.9.7 + DEBIAN_DISTRIBUTION="jessie" \ + DEBIAN_FRONTEND="noninteractive" \ + NODE_VERSION="4.x" \ + PHANTOMJS_VERSION="1.9.7" RUN \ apt-get update \ && apt-get install -y --no-install-recommends \ + apt-transport-https \ + && curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \ + && echo "deb https://deb.nodesource.com/node_${NODE_VERSION} ${DEBIAN_DISTRIBUTION} main" > /etc/apt/sources.list.d/nodesource.list && \ + && apt-get update && \ + && apt-get install -y --no-install-recommends \ + postgresql-client-9.4 \ apt-utils \ build-essential \ bzip2 \ gifsicle \ git \ graphicsmagick-imagemagick-compat \ - jhead \ + jhead \ jpegoptim \ libfontconfig \ libfreetype6 \ @@ -22,14 +30,16 @@ RUN \ libpq-dev \ nodejs \ optipng \ + postgresql-client-9.4 python-pip \ - postgresql-client-9.4 \ time \ vim \ wget \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* \ && pip install awscli \ + && npm config set "production" "true" \ + && npm config set "loglevel" "error" \ && npm install npm -g \ && npm install -g svgo From a5e174a670e71a9f6aef3162c25e4352e325ddbb Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 11:33:21 -0400 Subject: [PATCH 13/17] =?UTF-8?q?Fix=20a=20syntax=20error=20=F0=9F=98=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index af560c75b1092..ab9c111e753de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,8 @@ RUN \ && apt-get install -y --no-install-recommends \ apt-transport-https \ && curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \ - && echo "deb https://deb.nodesource.com/node_${NODE_VERSION} ${DEBIAN_DISTRIBUTION} main" > /etc/apt/sources.list.d/nodesource.list && \ - && apt-get update && \ + && echo "deb https://deb.nodesource.com/node_${NODE_VERSION} ${DEBIAN_DISTRIBUTION} main" > /etc/apt/sources.list.d/nodesource.list \ + && apt-get update \ && apt-get install -y --no-install-recommends \ postgresql-client-9.4 \ apt-utils \ @@ -30,7 +30,7 @@ RUN \ libpq-dev \ nodejs \ optipng \ - postgresql-client-9.4 + postgresql-client-9.4 \ python-pip \ time \ vim \ @@ -54,8 +54,7 @@ WORKDIR /code COPY Gemfile Gemfile.lock vendor ./ RUN \ - cd /app/ \ - && bundle install --jobs 20 --retry 5 \ + bundle install --jobs 20 --retry 5 \ && gem install parallel_tests COPY . ./ From 4047ec4af59843f8ea5862998cab98944ae1573b Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 12:29:01 -0400 Subject: [PATCH 14/17] Remove .git from .dockerignore Rspec tests require the meta data to be available --- .dockerignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index e761e03a93f2a..1f63fd9c0abc2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,3 @@ - -.git *.sublime-project aws_machines Brewfile From e3ce9600842ab10668a51208007c8d617fff66a2 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 12:58:58 -0400 Subject: [PATCH 15/17] Remove LICENSE.txt from .dockerignore Required by Rspec tests --- .dockerignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 1f63fd9c0abc2..05a14b4623bb2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,7 +8,6 @@ codeship-steps* codeship.aes CONTRIBUTING.md COPYRIGHT.txt -LICENSE.txt README.md tmp Vagrantfile From c412b279e3229177077af5e8b37aab89888df5a1 Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 13:03:09 -0400 Subject: [PATCH 16/17] Create missing folders --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index ab9c111e753de..8484a7a0b2a0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,3 +58,6 @@ RUN \ && gem install parallel_tests COPY . ./ + +RUN \ + mkdir -p ./public/backups/default tmp From b88a9e496969c114193e9e9f077f20952eef371e Mon Sep 17 00:00:00 2001 From: Marko Locher Date: Thu, 25 Aug 2016 13:56:05 -0400 Subject: [PATCH 17/17] Install PostgreSQL client 9.5 from official repos --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8484a7a0b2a0e..b0d02585d23c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,11 @@ RUN \ apt-transport-https \ && curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \ && echo "deb https://deb.nodesource.com/node_${NODE_VERSION} ${DEBIAN_DISTRIBUTION} main" > /etc/apt/sources.list.d/nodesource.list \ + && curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ + && echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_DISTRIBUTION}-pgdg main" > /etc/apt/sources.list.d/postgresql.list \ && apt-get update \ && apt-get install -y --no-install-recommends \ - postgresql-client-9.4 \ + postgresql-client-9.5 \ apt-utils \ build-essential \ bzip2 \