From 56e13d00f03a768d8f0ed75e0dc07521df92ae5e Mon Sep 17 00:00:00 2001 From: rhymes Date: Thu, 2 May 2019 18:06:18 +0200 Subject: [PATCH] Upgrade Ruby to 2.6.3 (#2649) --- .ruby-version | 2 +- .travis.yml | 2 +- Dockerfile | 210 +++++++++++++++++------------------ Gemfile | 2 +- Gemfile.lock | 2 +- README.md | 2 +- db/seeds.rb | 2 +- docker-entrypoint.sh | 4 +- docker-run.sh | 14 +-- docs/installation/docker.md | 47 +++++++- docs/installation/linux.md | 2 +- docs/installation/mac.md | 4 +- docs/installation/windows.md | 4 +- 13 files changed, 166 insertions(+), 131 deletions(-) diff --git a/.ruby-version b/.ruby-version index 6a6a3d8e35c7a..ec1cf33c3f6e2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.1 +2.6.3 diff --git a/.travis.yml b/.travis.yml index 9adfdf00229a4..9a55160090576 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ cache: - node_modules - $HOME/.nvm rvm: - - 2.6.1 + - 2.6.3 addons: postgresql: '9.6' chrome: stable diff --git a/Dockerfile b/Dockerfile index 20c8fc77942f8..a258d65420587 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ ##################################################### # -# Alpine container with +# Alpine container with # (this is used in DEV mode) -# -# + ruby:2.6.1 +# +# + ruby:2.6.3 # + node:8.15.0 # + yarn:1.12.3 # @@ -13,123 +13,119 @@ FROM node:8.15.1-alpine AS alpine-ruby-node #------------------------------------------------------------------------------------------ # # Ruby installation, taken from the official ruby alpine dockerfile -# see : https://github.com/docker-library/ruby/blob/96fc06fb331a20ba823ecc11563a99d1eb94203f/2.6/alpine3.9/Dockerfile +# see : https://github.com/docker-library/ruby/blob/9ae0943fa2935b3a13c72ae7d6afa2439145d7fa/2.6/alpine3.9/Dockerfile # #------------------------------------------------------------------------------------------ RUN apk add --no-cache \ - gmp-dev + gmp-dev # skip installing gem documentation RUN mkdir -p /usr/local/etc \ - && { \ - echo 'install: --no-document'; \ - echo 'update: --no-document'; \ - } >> /usr/local/etc/gemrc + && { \ + echo 'install: --no-document'; \ + echo 'update: --no-document'; \ + } >> /usr/local/etc/gemrc ENV RUBY_MAJOR 2.6 -ENV RUBY_VERSION 2.6.1 -ENV RUBY_DOWNLOAD_SHA256 47b629808e9fd44ce1f760cdf3ed14875fc9b19d4f334e82e2cf25cb2898f2f2 -ENV RUBYGEMS_VERSION 3.0.3 +ENV RUBY_VERSION 2.6.3 +ENV RUBY_DOWNLOAD_SHA256 11a83f85c03d3f0fc9b8a9b6cad1b2674f26c5aaa43ba858d4b0fcc2b54171e1 # some of ruby's build scripts are written in ruby # we purge system ruby later to make sure our final image uses what we just built # readline-dev vs libedit-dev: https://bugs.ruby-lang.org/issues/11869 and https://github.com/docker-library/ruby/issues/75 RUN set -ex \ - \ - && apk add --no-cache --virtual .ruby-builddeps \ - autoconf \ - bison \ - bzip2 \ - bzip2-dev \ - ca-certificates \ - coreutils \ - dpkg-dev dpkg \ - gcc \ - gdbm-dev \ - glib-dev \ - libc-dev \ - libffi-dev \ - libxml2-dev \ - libxslt-dev \ - linux-headers \ - make \ - ncurses-dev \ - openssl \ - openssl-dev \ - procps \ - readline-dev \ - ruby \ - tar \ - xz \ - yaml-dev \ - zlib-dev \ - \ - && wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \ - && echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \ - \ - && mkdir -p /usr/src/ruby \ - && tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \ - && rm ruby.tar.xz \ - \ - && cd /usr/src/ruby \ - \ -# https://github.com/docker-library/ruby/issues/196 -# https://bugs.ruby-lang.org/issues/14387#note-13 (patch source) -# https://bugs.ruby-lang.org/issues/14387#note-16 ("Therefore ncopa's patch looks good for me in general." -- only breaks glibc which doesn't matter here) - && wget -O 'thread-stack-fix.patch' 'https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch' \ - && echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum -c - \ - && patch -p1 -i thread-stack-fix.patch \ - && rm thread-stack-fix.patch \ - \ -# hack in "ENABLE_PATH_CHECK" disabling to suppress: -# warning: Insecure world writable dir - && { \ - echo '#define ENABLE_PATH_CHECK 0'; \ - echo; \ - cat file.c; \ - } > file.c.new \ - && mv file.c.new file.c \ - \ - && autoconf \ - && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ -# the configure script does not detect isnan/isinf as macros - && export ac_cv_func_isnan=yes ac_cv_func_isinf=yes \ - && ./configure \ - --build="$gnuArch" \ - --disable-install-doc \ - --enable-shared \ - && make -j "$(nproc)" \ - && make install \ - \ - && runDeps="$( \ - scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ - | tr ',' '\n' \ - | sort -u \ - | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - )" \ - && apk add --no-network --virtual .ruby-rundeps $runDeps \ - bzip2 \ - ca-certificates \ - libffi-dev \ - procps \ - yaml-dev \ - zlib-dev \ - && apk del --no-network .ruby-builddeps \ - && cd / \ - && rm -r /usr/src/ruby \ -# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246) - && ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))' \ - && gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/ \ -# rough smoke test - && ruby --version && gem --version && bundle --version + \ + && apk add --no-cache --virtual .ruby-builddeps \ + autoconf \ + bison \ + bzip2 \ + bzip2-dev \ + ca-certificates \ + coreutils \ + dpkg-dev dpkg \ + gcc \ + gdbm-dev \ + glib-dev \ + libc-dev \ + libffi-dev \ + libxml2-dev \ + libxslt-dev \ + linux-headers \ + make \ + ncurses-dev \ + openssl \ + openssl-dev \ + procps \ + readline-dev \ + ruby \ + tar \ + xz \ + yaml-dev \ + zlib-dev \ + \ + && wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \ + && echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \ + \ + && mkdir -p /usr/src/ruby \ + && tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \ + && rm ruby.tar.xz \ + \ + && cd /usr/src/ruby \ + \ + # https://github.com/docker-library/ruby/issues/196 + # https://bugs.ruby-lang.org/issues/14387#note-13 (patch source) + # https://bugs.ruby-lang.org/issues/14387#note-16 ("Therefore ncopa's patch looks good for me in general." -- only breaks glibc which doesn't matter here) + && wget -O 'thread-stack-fix.patch' 'https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch' \ + && echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum -c - \ + && patch -p1 -i thread-stack-fix.patch \ + && rm thread-stack-fix.patch \ + \ + # hack in "ENABLE_PATH_CHECK" disabling to suppress: + # warning: Insecure world writable dir + && { \ + echo '#define ENABLE_PATH_CHECK 0'; \ + echo; \ + cat file.c; \ + } > file.c.new \ + && mv file.c.new file.c \ + \ + && autoconf \ + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ + # the configure script does not detect isnan/isinf as macros + && export ac_cv_func_isnan=yes ac_cv_func_isinf=yes \ + && ./configure \ + --build="$gnuArch" \ + --disable-install-doc \ + --enable-shared \ + && make -j "$(nproc)" \ + && make install \ + \ + && runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )" \ + && apk add --no-network --virtual .ruby-rundeps $runDeps \ + bzip2 \ + ca-certificates \ + libffi-dev \ + procps \ + yaml-dev \ + zlib-dev \ + && apk del --no-network .ruby-builddeps \ + && cd / \ + && rm -r /usr/src/ruby \ + # rough smoke test + && ruby --version && gem --version && bundle --version # install things globally, for great justice # and don't create ".bundle" in all our apps ENV GEM_HOME /usr/local/bundle ENV BUNDLE_PATH="$GEM_HOME" \ - BUNDLE_SILENCE_ROOT_WARNING=1 \ - BUNDLE_APP_CONFIG="$GEM_HOME" + BUNDLE_SILENCE_ROOT_WARNING=1 \ + BUNDLE_APP_CONFIG="$GEM_HOME" # path recommendation: https://github.com/bundler/bundler/pull/6469#issuecomment-383235438 ENV PATH $GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH # adjust permissions of a few directories for running "gem install" as an arbitrary user @@ -163,7 +159,7 @@ ENV RAILS_ENV development # # This allow us to modify the docker # entrypoint / run file without recompiling -# the entire application +# the entire application # (especially when creating this buidl script =| ) # # (@TODO - improve and review ignore to blacklist unneded items) @@ -212,11 +208,11 @@ COPY Dockerfile [(docker-)]* /usr/src/app/ # Execution environment variables # -# timeout extension requried to ensure +# timeout extension requried to ensure # system work properly on first time load -ENV RACK_TIMEOUT_WAIT_TIMEOUT=10000 \ - RACK_TIMEOUT_SERVICE_TIMEOUT=10000 \ - STATEMENT_TIMEOUT=10000 +ENV RACK_TIMEOUT_WAIT_TIMEOUT=10000 \ + RACK_TIMEOUT_SERVICE_TIMEOUT=10000 \ + STATEMENT_TIMEOUT=10000 # Run mode configuration between dev / demo # for entrypoint script behaviour @@ -226,7 +222,7 @@ ENV RUN_MODE="demo" ENV DATABASE_URL="postgresql://devto:devto@db:5432/PracticalDeveloper_development" # DB setup / migrate script triggers on boot -ENV DB_SETUP="true" \ +ENV DB_SETUP="true" \ DB_MIGRATE="true" # diff --git a/Gemfile b/Gemfile index 52d9bb58cfa26..5a3591a4b52ac 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source "https://rubygems.org" -ruby "2.6.1" +ruby "2.6.3" # Enforce git to transmitted via https. # workaround until bundler 2.0 is released. diff --git a/Gemfile.lock b/Gemfile.lock index bbf60931c72d5..549f593c8f50c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -950,7 +950,7 @@ DEPENDENCIES zonebie (~> 0.6.1) RUBY VERSION - ruby 2.6.1p33 + ruby 2.6.3p62 BUNDLED WITH 1.17.3 diff --git a/README.md b/README.md index 269e06a3c556e..b1b0b508931c0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

- ruby version + ruby version rails version diff --git a/db/seeds.rb b/db/seeds.rb index 04f96dfe4041d..e4c97c68dfa1b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2,7 +2,7 @@ 3.times do Organization.create!( - name: Faker::SiliconValley.company, + name: Faker::TvShows::SiliconValley.company, summary: Faker::Company.bs, remote_profile_image_url: logo = Faker::Company.logo, nav_image: logo, diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5328f014a7a42..fc09646f0a064 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -22,7 +22,7 @@ then echo ">---" echo "> [dev.to/docker-entrypoint.sh] DEV mode" echo "> " - echo "> Welcome to the dev.to, DEVELOPMENT container, for convinence your repository" + echo "> Welcome to the dev.to, DEVELOPMENT container, for convenience your repository" echo "> should be mounted onto '/usr/src/app/', and port 3000 should be forwarded to your host machine" echo "> " echo "> In addition the following alias commands has been preconfigured to get you up and running quickly" @@ -49,7 +49,7 @@ echo "> Time to rock & roll" echo ">---" # -# DB setup +# DB setup # note this will fail (intentionally), if DB was previously setup # if [[ "$DB_SETUP" == "true" ]] diff --git a/docker-run.sh b/docker-run.sh index 7a424de30c432..8efcc62aba283 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -22,7 +22,7 @@ then echo "| For this container to work, we will need at minimum ALGOLIA API keys" echo "| For logins to work, we will need either GITHUB or TWITTER API keys" echo "|" - echo "| See ( https://docs.dev.to/get-api-keys-dev-env/ ) " + echo "| See ( https://docs.dev.to/getting-started/config-env/ ) " echo "| for instructions on how to get the various API keys " echo "|" echo "| Once you got your various API keys, please proceed to the next step" @@ -114,7 +114,7 @@ fi ########################################### # -# Script header guide +# Script header guide # ########################################### @@ -140,12 +140,12 @@ echo "#" echo "# RUN_MODE can either be the following" echo "#" echo "# - 'DEV' : Start up the container into bash, with a quick start guide" -echo "# - 'DEMO' : Start up the container, and run dev.to (requries ALGOLIA environment variables)" +echo "# - 'DEMO' : Start up the container, and run dev.to (requires ALGOLIA environment variables)" echo "# - 'RESET-DEV' : Resets postgresql and upload data directory for a clean deployment, before running as DEV mode" echo "# - 'RESET-DEMO' : Resets postgresql and upload data directory for a clean deployment, before running as DEMO mode" echo "# - 'INTERACTIVE-DEMO' : Runs this script in 'interactive' mode to setup the 'DEMO'" echo "#" -echo "# So for example to run a development container in bash its simply" +echo "# So for example to run a development container in bash it's simply" echo "# './docker-run.sh DEV'" echo "#" echo "# To run a simple demo, with some dummy data (replace with the actual keys)" @@ -439,7 +439,7 @@ mkdir -p "$UPLOAD_DIR" # # in DEV mode - lets run in interactive mode # -if [ "$RUN_MODE" = "DEV" ] +if [ "$RUN_MODE" = "DEV" ] then docker run -it -p 3000:3000 \ --name dev-to-app \ @@ -472,7 +472,7 @@ dev-to:demo # this waits up to ~20*30 seconds # echo "#---" -echo "# Waiting for dev.to server... " +echo "# Waiting for dev.to server... " echo "#" echo "# this commonly takes 2 ~ 10 minutes, basically, a very long time .... =[ " @@ -506,7 +506,7 @@ echo "$DOCKER_INFO" | grep dev-to- # Finishing message # echo "#---" -echo "# Container deployed on port ( http://localhost:3000 )" +echo "# Container deployed on address ( http://localhost:3000 )" echo "# " echo "# Time to dev.to(gether)" echo "#---" diff --git a/docs/installation/docker.md b/docs/installation/docker.md index 20059a4e3ed66..cc1c6e6ad80f5 100644 --- a/docs/installation/docker.md +++ b/docs/installation/docker.md @@ -1,10 +1,49 @@ -# Docker Installation [Beta] +# Installing DEV with Docker [Beta] + +## Installing prerequites + +_These prerequisites assume you're working on an operating system supported by Docker._ + +### Docker and Docker Compose + +Docker is available for many different operating systems. We recommend you follow the [Docker CE install guide](https://docs.docker.com/install/) which illustrates multiple installation options for each OS. + +You're also going to need Docker Compose, to start multiple containers. We recommend you follow the [Docker Compose install guide](https://docs.docker.com/compose/install/) as well. + +## Installing DEV + +1. Fork DEV's repository, eg. +1. Clone your forked repository, eg. `git clone https://github.com//dev.to.git` +1. Set up your environment variables/secrets + + - Take a look at `Envfile`. This file lists all the `ENV` variables we use and provides a fake default for any missing keys. You'll need to get your own free [Algolia credentials](/backend/algolia) to get your development environment running. + - The [backend guide](/backend) will show you how to get free API keys for additional services that may be required to run certain parts of the app. + - For any key that you wish to enter/replace: + + 1. Create `config/application.yml` by copying from the provided template (ie. with bash: `cp config/sample_application.yml config/application.yml`). This is a personal file that is ignored in git. + 1. Obtain the development variable and apply the key you wish to enter/replace. ie: + + ```shell + GITHUB_KEY: "SOME_REAL_SECURE_KEY_HERE" + GITHUB_SECRET: "ANOTHER_REAL_SECURE_KEY_HERE" + ``` + + - You do not need "real" keys for basic development. Some features require certain keys, so you may be able to add them as you go. + +## Running the Docker app (basic) -1. Install `docker` and `docker-compose` -1. `git clone git@github.com:thepracticaldev/dev.to.git` -1. Set environment variables above as described in the "Basic Installation" 1. run `docker-compose build` 1. run `docker-compose run web rails db:setup` 1. run `docker-compose run web yarn install` 1. run `docker-compose up` 1. That's it! Navigate to + +## Running the Docker app (advanced) + +DEV provides a `docker-run.sh` script which can be used to run the Docker app with custom options. + +Please execute the script itself to view all additional options: + +```shell +./docker-run.sh +``` diff --git a/docs/installation/linux.md b/docs/installation/linux.md index 600d0def56d8f..ae0180b9045ca 100644 --- a/docs/installation/linux.md +++ b/docs/installation/linux.md @@ -7,7 +7,7 @@ _These prerequisites assume you're working on a Linux-based operating system but ### Ruby 1. If you don't already have a Ruby version manager, we highly recommend [rbenv](https://github.com/rbenv/rbenv). Please follow their [installation guide](https://github.com/rbenv/rbenv#installation). -1. With the Ruby version manager, install the Ruby version listed on our badge. (ie with rbenv: `rbenv install 2.6.1`) +1. With the Ruby version manager, install the Ruby version listed on our badge. (ie with rbenv: `rbenv install 2.6.3`) For very detailed rbenv installation directions on several distros, please visit [DigitalOcean's guide](https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-18-04). diff --git a/docs/installation/mac.md b/docs/installation/mac.md index 046499a3ea31e..1a900feec48d9 100644 --- a/docs/installation/mac.md +++ b/docs/installation/mac.md @@ -9,7 +9,7 @@ title: macOS ### Ruby 1. If you don't already have a Ruby version manager, we highly recommend [rbenv](https://github.com/rbenv/rbenv). Please follow their [installation guide](https://github.com/rbenv/rbenv#installation). -2. With the Ruby version manager, install the Ruby version listed on our badge. (ie with rbenv: `rbenv install 2.6.1`) +2. With the Ruby version manager, install the Ruby version listed on our badge. (ie with rbenv: `rbenv install 2.6.3`) ### Yarn @@ -71,7 +71,7 @@ Run the following to update `ruby-build`, `brew update && brew upgrade ruby-buil rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get install libreadline-dev` and then reinstall your Ruby. rails aborted! -LoadError: dlopen(/Users//.rbenv/versions/2.6.1/lib/ruby/2.6.0/x86_64-darwin18/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline..dylib +LoadError: dlopen(/Users//.rbenv/versions/2.6.3/lib/ruby/2.6.0/x86_64-darwin18/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline..dylib ``` **_Solution:_** Run `ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline..dylib` from the command line then run `bin/setup` again. You may have a different version or libreadline, so replace `` with the version that errored. diff --git a/docs/installation/windows.md b/docs/installation/windows.md index 5032618fe5d6f..c18c5fb6375fb 100644 --- a/docs/installation/windows.md +++ b/docs/installation/windows.md @@ -38,8 +38,8 @@ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL -rbenv install 2.6.1 -rbenv global 2.6.1 +rbenv install 2.6.3 +rbenv global 2.6.3 ruby -v ```