Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Opening Open-Source with DevOps

Opening Open-Source with DevOps

by Tim Perry
DevOps Pro Vilnius 2016

DevOps Pro

June 01, 2016
Tweet

More Decks by DevOps Pro

Other Decks in Technology

Transcript

  1. “Sequelize is a promise-based ORM for Node.js and io.js. It

    supports the dialects PostgreSQL, MySQL, MariaDB, SQLite and MSSQL and features solid transaction support, relations, read replication and more.”
  2. FROM node:6 RUN apt-get install libpq-dev COPY package.json / ENV

    NPM_CONFIG_LOGLEVEL error RUN npm install WORKDIR /sequelize VOLUME /sequelize Dockerfile
  3. sequelize: build: . links: - mysql - postgres volumes: -

    .:/sequelize environment: SEQ_DB: sequelize_test SEQ_USER: sequelize_test SEQ_PW: sequelize_test JSHINT: /node_modules/.bin/jshint MOCHA: /node_modules/.bin/mocha postgres: image: postgres:9.4 environment: POSTGRES_USER: sequelize_test POSTGRES_PASSWORD: sequelize_test mysql: image: mysql:5.6 environment: MYSQL_DATABASE: sequelize_test MYSQL_USER: sequelize_test MYSQL_PASSWORD: sequelize_test docker-compose.yml
  4. 24 Pull Requests Install rbenv and ruby-build Install Ruby 2.3.1

    Install Postgres Configure Postgres Install Node.js and PhantomJS Install gem dependencies Create the required databases Run all the migrations for them Load the sample data Set up mailcatcher for email Start the server Local Dev Setup
  5. --- - hosts: all vars: timezone: UTC sys_packages: - python-software-properties

    - build-essential - libssl-dev - libreadline-dev - libpq-dev vars_files: - vars/pgsql.yml roles: - init - ruby - pgsql - app 24 Pull Requests playbook.yml (simplified)
  6. --- - hosts: all vars: timezone: UTC sys_packages: - python-software-properties

    - build-essential - libssl-dev - libreadline-dev - libpq-dev vars_files: - vars/pgsql.yml roles: - init - ruby - pgsql - app playbook.yml (simplified) 24 Pull Requests
  7. --- - name: Add ppa Repository - Node apt_repository: repo=ppa:chris-lea/node.js

    - name: Install NodeJS and PhantomJS apt: pkg={{ item }} state=latest with_items: - nodejs - phantomjs - name: Install Gems sudo: false shell: bundler install --path vendor/bundle - name: Rake db:create sudo: false shell: bundle exec rake db:create:all - name: Rake db:migrate sudo: false shell: bundle exec rake db:migrate - name: Feed DB sudo: false shell: bundle exec rake db:seed roles/app/tasks/main.yml (simplified) 24 Pull Requests
  8. Vagrant.configure("2") do |config| config.vm.provider :virtualbox do |v| v.name = "TFPullRequests"

    v.customize ["modifyvm", :id, "--memory", 1024] end config.vm.box = "ubuntu/trusty64" config.vm.network :private_network, ip: "192.168.12.34" config.ssh.forward_agent = true if which('ansible-playbook') config.vm.provision "ansible" do |ansible| ansible.playbook = "ansible/playbook.yml" ansible.inventory_path = "ansible/inventories/dev" ansible.limit = 'all' end else config.vm.provision :shell, path: "ansible/windows.sh" end config.vm.synced_folder "./", "/vagrant", type: "nfs" end 24 Pull Requests Vagrantfile (simplified)
  9. Install rbenv and ruby-build Install Ruby 2.1 Install MySQL Configure

    MySQL Create DB and app user in MySQL Clone codebase from Github Bundle install dependencies Fill out Staytus’s config files Run rake tasks to set up database schema Start the server Setting up Staytus
  10. Install rbenv and ruby-build Install Ruby 2.1 Install MySQL Configure

    MySQL Create DB and app user in MySQL Clone codebase from Github Bundle install dependencies Fill out Staytus’s config files Run rake tasks to set up database schema Start the server Setting up Staytus
  11. Dockerfile (simplified) FROM ruby USER root # Add MySQL to

    this image (generally not good practice!) RUN apt-get update && \ export DEBIAN_FRONTEND=noninteractive && \ echo mysql-server mysql-server/root_password \ password temp-password | \ debconf-set-selections && \ echo mysql-server mysql-server/root_password_again \ password temp-password | \ debconf-set-selections && \ apt-get install -y mysql-server nodejs COPY . /opt/staytus RUN cd /opt/staytus && \ bundle install --deployment --without development:test ENTRYPOINT /opt/staytus/docker-start.sh VOLUME /var/lib/mysql VOLUME /opt/staytus/persisted EXPOSE 5000
  12. #!/bin/bash /etc/init.d/mysql start cd /opt/staytus if [ ! -f /opt/staytus/persisted/config/database.yml

    ]; then # Configure DB with random password, if not already configured export RANDOM_PASSWORD=`openssl rand -base64 32` mysqladmin -u root -ptemp-password password $RANDOM_PASSWORD echo "CREATE DATABASE staytus COLLATE utf8_unicode_ci" | \ mysql -u root -p$RANDOM_PASSWORD cp config/database.example.yml config/database.yml sed -i "s/username:.*/username: root/" config/database.yml sed -i "s|password:.*|password: $RANDOM_PASSWORD|" config/database.yml mkdir /opt/staytus/persisted/config cp config/database.yml /opt/staytus/persisted/config/database.yml bundle exec rake staytus:build staytus:install else cp /opt/staytus/persisted/config/database.yml config/database.yml # If already configured, check if there are any migrations to run bundle exec rake staytus:build staytus:upgrade fi bundle exec foreman start docker-start.sh (simplified)
  13. maintainer "GitLab Inc. <[email protected]>" homepage "https://about.gitlab.com/" install_dir "/opt/gitlab" build_version Omnibus::BuildVersion.new.semver

    build_iteration Gitlab::BuildIteration.new.build_iteration override :ruby, version: '2.1.8', source: { md5: '091b62f0...' } override :rubygems, version: 'v2.5.1' override :pip, version: '7.1.2', source: { md5: '3823d234...' } override :redis, version: '2.8.24', source: { md5: '7b6eb6...' } override :postgresql, version: '9.2.1', source: { md5: '...' } override :liblzma, version: '5.2.2', source: { md5: '7cf6a...' } runtime_dependency "openssh-server" dependency "redis" dependency "nginx" dependency "remote-syslog" if ee dependency "nodejs" dependency "gitlab-shell" dependency "gitlab-cookbooks" dependency "gitlab-selinux" dependency "gitlab-config-template" dependency "mattermost" exclude "\.git*" package_user 'root' package_group 'root' config/projects/gitlab.rb (simplified)
  14. name "nginx" default_version "1.9.12" dependency "pcre" dependency "openssl" source url:

    "http://nginx.org/download/nginx-#{version}.tar.gz", md5: "0afe4a7e589a0de43b7b54aa055a4351" relative_path "nginx-#{version}" build do command ["./configure", "--prefix=#{install_dir}/embedded", "--with-http_ssl_module", "--with-http_gzip_static_module", "--with-http_v2_module", "--with-http_realip_module", "--with-ipv6", "--with-debug"].join(" ") command "make install" end config/software/nginx.rb (simplified)
  15. How can DevOps make Open Source more accessible? Create Confidence

    inspiring Test Environments Make developer setup effortless Distribute painless setup tools