Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewd committed Feb 5, 2019
0 parents commit 3749492
Show file tree
Hide file tree
Showing 7 changed files with 466 additions and 0 deletions.
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ARG RUBY_IMAGE
FROM ${RUBY_IMAGE:-ruby:latest}

RUN gem update --system && gem install bundler \
&& ruby --version && gem --version && bundle --version \
&& echo "--- :package: Installing system deps" \
# Postgres apt sources
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
# Node apt sources
&& curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb http://deb.nodesource.com/node_10.x stretch main" > /etc/apt/sources.list.d/nodesource.list \
# Yarn apt sources
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
# Install all the things
&& apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-client mysql-client sqlite3 \
git nodejs yarn lsof \
ffmpeg mupdf mupdf-tools poppler-utils \
# await (for waiting on dependent services)
&& cd /tmp \
&& wget -qc https://github.com/betalo-sweden/await/releases/download/v0.4.0/await-linux-amd64 \
&& install await-linux-amd64 /usr/local/bin/await \
# clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* \
&& mkdir /rails

WORKDIR /rails
ENV RAILS_ENV=test RACK_ENV=test
ENV JRUBY_OPTS="--dev -J-Xmx1024M"

ADD .buildkite/await-all /usr/local/bin/

ADD actioncable/package.json actioncable/
ADD actiontext/package.json actiontext/
ADD actionview/package.json actionview/
ADD activestorage/package.json activestorage/
ADD package.json yarn.lock .yarnrc ./

RUN echo "--- :javascript: Installing JavaScript deps" \
&& yarn install \
&& yarn cache clean

ADD */*.gemspec tmp/
ADD railties/exe/ railties/exe/
ADD Gemfile Gemfile.lock RAILS_VERSION rails.gemspec ./

RUN echo "--- :bundler: Installing Ruby deps" \
&& (cd tmp && for f in *.gemspec; do d="$(basename -s.gemspec "$f")"; mkdir -p "../$d" && mv "$f" "../$d/"; done) \
&& rm Gemfile.lock && bundle install -j 8 && cp Gemfile.lock tmp/Gemfile.lock.updated \
&& rm -rf /usr/local/bundle/gems/cache \
&& echo "--- :floppy_disk: Copying repository contents"

ADD . ./

RUN mv -f tmp/Gemfile.lock.updated Gemfile.lock
6 changes: 6 additions & 0 deletions Dockerfile.beanstalkd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine

RUN apk add --no-cache beanstalkd

EXPOSE 11300
ENTRYPOINT ["/usr/bin/beanstalkd"]
7 changes: 7 additions & 0 deletions await-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

exec await $(
getent hosts $(
for v in ${!AWAIT_*}; do echo ${v#AWAIT_}; done
) | while read ip name; do v="AWAIT_${name}"; echo ${!v}; done
) -- "$@"
115 changes: 115 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
version: "3.6"

services:
base:
build:
context: ../
dockerfile: .buildkite/Dockerfile
args:
- RUBY_IMAGE

default: &default
image: "${IMAGE_NAME-buildkite_base}"
environment:
CI:
BUILDKITE_PARALLEL_JOB:
BUILDKITE_PARALLEL_JOB_COUNT:

# Sauce Labs username and access key. Obfuscated, purposefully not encrypted.
ENCODED: "U0FVQ0VfQUNDRVNTX0tFWT1hMDM1MzQzZi1lOTIyLTQwYjMtYWEzYy0wNmIzZWE2MzVjNDggU0FVQ0VfVVNFUk5BTUU9cnVieW9ucmFpbHM="

BEANSTALK_URL: "beanstalk://beanstalkd"
MEMCACHE_SERVERS: "memcached:11211"
MYSQL_HOST: "${MYSQL_SERVICE-mysql}"
PGHOST: postgres
PGUSER: postgres
QC_DATABASE_URL: "postgres://postgres@postgres/active_jobs_qc_int_test"
QUE_DATABASE_URL: "postgres://postgres@postgres/active_jobs_que_int_test"
RABBITMQ_URL: "amqp://guest:guest@rabbitmq:5672"
REDIS_URL: "redis://redis:6379/1"
SELENIUM_DRIVER_URL: "http://chrome:4444/wd/hub"

AWAIT_redis: tcp://redis:6379
AWAIT_memcached: tcp://memcached:11211
AWAIT_mysql: tcp://mysql:3306
AWAIT_mariadb: tcp://mariadb:3306
AWAIT_postgres: postgres://postgres@postgres:5432/postgres
AWAIT_rabbitmq: tcp://rabbitmq:5672
AWAIT_beanstalkd: tcp://beanstalkd:11300
AWAIT_chrome: tcp://chrome:4444

entrypoint: await-all

depends_on:
- redis
- memcached

postgresdb:
<<: *default
depends_on:
- redis
- memcached
- postgres

mysqldb:
<<: *default
depends_on:
- redis
- memcached
- "${MYSQL_SERVICE-mysql}"

railties:
<<: *default
depends_on:
- redis
- memcached
- "${MYSQL_SERVICE-mysql}"
- postgres

activejob:
<<: *default
depends_on:
- redis
- memcached
- postgres
- rabbitmq
- beanstalkd

actionview:
<<: *default
depends_on:
- redis
- memcached
- chrome

memcached:
image: memcached:alpine

redis:
image: redis:alpine

mysql: &mysql
image: mysql:latest
command: "--default-authentication-plugin=mysql_native_password"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- "./mysql-initdb.d:/docker-entrypoint-initdb.d"

mariadb:
<<: *mysql
image: mariadb:latest

postgres:
image: postgres:alpine

rabbitmq:
image: rabbitmq:alpine

beanstalkd:
build:
context: ./
dockerfile: Dockerfile.beanstalkd

chrome:
image: selenium/standalone-chrome:latest
48 changes: 48 additions & 0 deletions initial.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This file is never read -- it's just a copy of the pipeline's
# configuration in the Buildkite UI.

steps:
- name: ":pipeline:"
command: |
PATH=/bin:/usr/bin
treesha="$$(git ls-tree -d HEAD .buildkite | awk '{print $$3}')"
if [ -z "$${treesha}" ]; then
echo "+++ No .buildkite/; using fallback repository"
rm -rf .buildkite
git clone "https://github.com/rails/buildkite-config" .buildkite
sh -c "$$PIPELINE_COMMAND"
elif [ "$${#treesha}" -lt 40 ]; then
echo "Short SHA for .buildkite/"
exit 1
elif curl -s -S "https://gist.githubusercontent.com/matthewd/3f98bcc9957c8ddf2204a390bf3a6cdd/raw/list" | grep -a -F -x "$${treesha}"; then
echo "+++ Known tree; generating pipeline"
echo ".buildkite/ tree is $${treesha}"
sh -c "$$PIPELINE_COMMAND"
else
echo "+++ Unknown tree; requesting approval"
echo ".buildkite/ tree is $${treesha}"
buildkite-agent pipeline upload <<'NESTED'
steps:
- block: "Review Build Script"
prompt: |
This commit uses new build configuration. Please review the changes in .buildkite/ carefully before unblocking.
- name: ":pipeline:"
command: >-
$$PIPELINE_COMMAND
timeout_in_minutes: 5
NESTED
fi
env:
PIPELINE_COMMAND: >-
docker run --rm
-v "$$PWD":/app:ro -w /app
-e CI
-e BUILDKITE_BRANCH
-e BUILDKITE_BUILD_ID
-e BUILDKITE_PULL_REQUEST
-e BUILDKITE_PULL_REQUEST_BASE_BRANCH
-e BUILDKITE_REBUILT_FROM_BUILD_ID
ruby:latest
.buildkite/pipeline-generate |
buildkite-agent pipeline upload
timeout_in_minutes: 5
6 changes: 6 additions & 0 deletions mysql-initdb.d/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create user rails@'%';
grant all privileges on activerecord_unittest.* to rails@'%';
grant all privileges on activerecord_unittest2.* to rails@'%';
grant all privileges on inexistent_activerecord_unittest.* to rails@'%';
create database activerecord_unittest default character set utf8mb4;
create database activerecord_unittest2 default character set utf8mb4;
Loading

0 comments on commit 3749492

Please sign in to comment.