From 648703bb93e190d9a03c9ebaeb1b4bf0beffd8c7 Mon Sep 17 00:00:00 2001 From: Subramanya Chakravarthy Date: Wed, 18 Mar 2020 09:18:31 +0530 Subject: [PATCH] Add ruby 2.7 --- 2.7.0/Dockerfile | 37 +++++++++++ 2.7.0/README.txt | 1 + 2.7.0/hostingstart.html | 2 + 2.7.0/init_container.sh | 26 ++++++++ 2.7.0/sshd_config | 15 +++++ 2.7.0/startup.sh | 116 +++++++++++++++++++++++++++++++++++ 2.7.0/staticsite.rb | 7 +++ base_images/2.7.0/Dockerfile | 61 ++++++++++++++++++ 8 files changed, 265 insertions(+) create mode 100644 2.7.0/Dockerfile create mode 100644 2.7.0/README.txt create mode 100644 2.7.0/hostingstart.html create mode 100644 2.7.0/init_container.sh create mode 100644 2.7.0/sshd_config create mode 100644 2.7.0/startup.sh create mode 100644 2.7.0/staticsite.rb create mode 100644 base_images/2.7.0/Dockerfile diff --git a/2.7.0/Dockerfile b/2.7.0/Dockerfile new file mode 100644 index 0000000..924f2bd --- /dev/null +++ b/2.7.0/Dockerfile @@ -0,0 +1,37 @@ +FROM appsvc/rubybase:2.7.0 +LABEL maintainer="Azure App Services Container Images " + +COPY init_container.sh /bin/ +COPY startup.sh /opt/ +COPY sshd_config /etc/ssh/ +COPY hostingstart.html /opt/startup/hostingstart.html +COPY staticsite.rb /opt/staticsite.rb + +RUN apt-get update -qq \ + && apt-get install -y nodejs openssh-server vim curl wget tcptraceroute --no-install-recommends \ + && echo "root:Docker!" | chpasswd \ + && echo "cd /home" >> /etc/bash.bashrc + +RUN eval "$(rbenv init -)" \ + && rbenv global 2.7.0 + +RUN chmod 755 /bin/init_container.sh \ + && mkdir -p /home/LogFiles/ \ + && chmod 755 /opt/startup.sh + +EXPOSE 2222 8080 + +ENV PORT 8080 +ENV SSH_PORT 2222 +ENV WEBSITE_ROLE_INSTANCE_ID localRoleInstance +ENV WEBSITE_INSTANCE_ID localInstance +ENV PATH ${PATH}:/home/site/wwwroot + +# install libssl1.0.2 +RUN wget http://ftp.us.debian.org/debian/pool/main/o/openssl1.0/libssl1.0.2_1.0.2q-1~deb9u1_amd64.deb \ + && apt-get install dialog \ + && dpkg -i libssl1.0.2_1.0.2q-1~deb9u1_amd64.deb + +WORKDIR /home/site/wwwroot + +ENTRYPOINT [ "/bin/init_container.sh" ] diff --git a/2.7.0/README.txt b/2.7.0/README.txt new file mode 100644 index 0000000..5c6c91f --- /dev/null +++ b/2.7.0/README.txt @@ -0,0 +1 @@ +This image is in development, not yet a working state. Use 2.3-1 for personal testing. diff --git a/2.7.0/hostingstart.html b/2.7.0/hostingstart.html new file mode 100644 index 0000000..d55a3f6 --- /dev/null +++ b/2.7.0/hostingstart.html @@ -0,0 +1,2 @@ + +Microsoft Azure App Service - Welcome

Hey, Ruby developers!


Your app service is up and running.

Time to take the next step and deploy your code.

Have your code ready?
Use deployment center to get code published from your client or setup continuous deployment.

Don't have your code yet?
Follow our quickstart guide and you'll have a full app ready in 5 minutes or less.

\ No newline at end of file diff --git a/2.7.0/init_container.sh b/2.7.0/init_container.sh new file mode 100644 index 0000000..cb6f798 --- /dev/null +++ b/2.7.0/init_container.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +cat >/etc/motd < + \/ \/ \/ +A P P S E R V I C E O N L I N U X + +Documentation: http://aka.ms/webapp-linux +Ruby quickstart: https://aka.ms/ruby-qs + +EOL +cat /etc/motd + +sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config +service ssh start + +# Get environment variables to show up in SSH session +eval $(printenv | awk -F= '{print "export " $1"="$2 }' >> /etc/profile) + +eval "$(rbenv init -)" +rbenv global 2.6.2 +/opt/startup.sh "$@" + diff --git a/2.7.0/sshd_config b/2.7.0/sshd_config new file mode 100644 index 0000000..7787ce7 --- /dev/null +++ b/2.7.0/sshd_config @@ -0,0 +1,15 @@ +# This is ssh server systemwide configuration file. +# +# /etc/sshd_config + +Port SSH_PORT +ListenAddress 0.0.0.0 +LoginGraceTime 180 +X11Forwarding yes +Ciphers aes128-cbc,3des-cbc,aes256-cbc +MACs hmac-sha1,hmac-sha1-96 +StrictModes yes +SyslogFacility DAEMON +PasswordAuthentication yes +PermitEmptyPasswords no +PermitRootLogin yes diff --git a/2.7.0/startup.sh b/2.7.0/startup.sh new file mode 100644 index 0000000..795b27f --- /dev/null +++ b/2.7.0/startup.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash + +if ! [ -e /home/site/wwwroot/Gemfile ] && [ -z "$RAILS_IGNORE_SPLASH" ] + then + echo 'No Gemfile found and RAILS_IGNORE_SPLASH not set, running default static site' + exec ruby /opt/staticsite.rb +fi + +if [ -z "$BUNDLE_WITHOUT" ]; then + echo "Bundle install with no 'without' options"; + RUBY_OPTIONS=""; +else + RUBY_OPTIONS="--without $BUNDLE_WITHOUT"; + echo "Bundle install with options $RUBY_OPTIONS"; +fi + +if [ -z "$BUNDLE_INSTALL_LOCATION" ]; then + echo "Defaulting gem installation directory to /tmp/bundle"; + BUNDLE_INSTALL_LOCATION="/tmp/bundle"; +else + echo "Gem installation directory is $BUNDLE_INSTALL_LOCATION"; +fi + +if [ -z "$RUBY_SITE_CONFIG_DIR" ]; then + echo "Defaulting site config directory to /home/site/config"; + RUBY_SITE_CONFIG_DIR="/home/site/config" +else + echo "site config directory is $RUBY_SITE_CONFIG_DIR"; +fi + +if [ -n "$SECRET_KEY_BASE" ] + then + echo 'Secret key base present' + else + echo 'Generating a secret key base' + export SECRET_KEY_BASE=$(ruby -rsecurerandom -e 'puts SecureRandom.hex(64)') +fi + +if [ -n "$RAILS_ENV" ] + then + echo "RAILS_ENV set to $RAILS_ENV" + else + echo 'RAILS_ENV not set, default to production' + export RAILS_ENV='production' +fi + +echo 'Removing any leftover pids if present' +rm -f tmp/pids/* ; + +# Support zipped gems +export ZIPPED_GEMS=0 +if [ -f "${RUBY_SITE_CONFIG_DIR}/gems.tgz" ] + then + echo "gems.tgz detected, beginning unzipping process" + echo "unzipping..." + mkdir -p $BUNDLE_INSTALL_LOCATION + cp ${RUBY_SITE_CONFIG_DIR}/gems.tgz /tmp + tar -C $BUNDLE_INSTALL_LOCATION -xf /tmp/gems.tgz + + echo 'Removing bundler config' + rm -f ${BUNDLE_INSTALL_LOCATION}/config + + export ZIPPED_GEMS=1 +fi + +export CHECK_PASSED=0 +echo 'Running bundle check' +if [ "$ZIPPED_GEMS" -eq 1 ] + then + bundle config --global path $BUNDLE_INSTALL_LOCATION + if bundle check | grep satisfied + then + echo 'dependency check passed' + export CHECK_PASSED=1 + else + echo 'missing dependencies, try redeploying' + echo `bundle check` + fi + else + bundle config --local path "vendor/bundle" + if bundle check --path "vendor/bundle" | grep satisfied + then + echo 'dependency check passed' + export CHECK_PASSED=1 + else + echo 'missing dependencies, try redeploying' + echo `bundle check --path "vendor/bundle"` + fi +fi + +if [ "$CHECK_PASSED" -eq 0 ] + then + if [ "$ZIPPED_GEMS" -eq 1 ] + then + echo "running bundle install $RUBY_OPTIONS --no-deployment" + bundle install --no-deployment $RUBY_OPTIONS + else + echo "running bundle install $RUBY_OPTIONS --local --path vendor/bundle" + bundle install $RUBY_OPTIONS --local --path vendor/bundle + fi +fi + +if [ -n "$GEM_PRISTINE" ] + then + echo 'running "gem pristine --all"' + bundle exec gem pristine --all +fi + +if [ $# -ne 0 ] + then + echo "Executing $@" + exec "$@" + else + echo "defaulting to command: \"bundle exec rails server -e $RAILS_ENV -p $PORT\"" + exec bundle exec rails server -b 0.0.0.0 -e "$RAILS_ENV" -p "$PORT" +fi \ No newline at end of file diff --git a/2.7.0/staticsite.rb b/2.7.0/staticsite.rb new file mode 100644 index 0000000..34814f7 --- /dev/null +++ b/2.7.0/staticsite.rb @@ -0,0 +1,7 @@ +require 'webrick' +options = { + :Port => ENV["PORT"].to_i, + :DirectoryIndex => ["hostingstart.html"], + :DocumentRoot => '/opt/startup' +} +WEBrick::HTTPServer.new(options).start diff --git a/base_images/2.7.0/Dockerfile b/base_images/2.7.0/Dockerfile new file mode 100644 index 0000000..7b3426d --- /dev/null +++ b/base_images/2.7.0/Dockerfile @@ -0,0 +1,61 @@ +FROM buildpack-deps:jessie-curl +LABEL maintainer="Azure App Services Container Images " + +RUN echo "deb http://deb.debian.org/debian/ jessie main" > /etc/apt/sources.list \ + && echo "deb-src http://deb.debian.org/debian/ jessie main" >> /etc/apt/sources.list \ + && echo "deb http://security.debian.org/ jessie/updates main" >> /etc/apt/sources.list \ + && echo "deb-src http://security.debian.org/ jessie/updates main" >> /etc/apt/sources.list \ + && echo "deb http://archive.debian.org/debian jessie-backports main" >> /etc/apt/sources.list \ + && echo "deb-src http://archive.debian.org/debian jessie-backports main" >> /etc/apt/sources.list \ + && echo "Acquire::Check-Valid-Until \"false\";" > /etc/apt/apt.conf + +RUN apt-get update -qq + +# Dependencies for various ruby and rubygem installations +RUN apt-get install -y git --no-install-recommends +RUN apt-get install -y libreadline-dev bzip2 build-essential libssl-dev zlib1g-dev libpq-dev libsqlite3-dev \ + curl patch gawk g++ gcc make libc6-dev patch libreadline6-dev libyaml-dev sqlite3 autoconf \ + libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev bison libxslt-dev \ + libxml2-dev libmysqlclient-dev --no-install-recommends + +# rbenv +RUN git clone https://github.com/rbenv/rbenv.git /usr/local/.rbenv +RUN chmod -R 777 /usr/local/.rbenv + +ENV RBENV_ROOT="/usr/local/.rbenv" + +ENV PATH="$RBENV_ROOT/bin:/usr/local:$PATH" + +RUN git clone https://github.com/rbenv/ruby-build.git /usr/local/.rbenv/plugins/ruby-build +RUN chmod -R 777 /usr/local/.rbenv/plugins/ruby-build + +RUN /usr/local/.rbenv/plugins/ruby-build/install.sh + +# Install ruby 2.7.0 +ENV RUBY_CONFIGURE_OPTS=--disable-install-doc + +ENV RUBY_CFLAGS=-O3 + +RUN eval "$(rbenv init -)" \ + && export WEBSITES_LATEST_NODE_VERSION="2.7.0" \ + && rbenv install $WEBSITES_LATEST_NODE_VERSION \ + && rbenv rehash \ + && rbenv global $WEBSITES_LATEST_NODE_VERSION \ + && ls /usr/local -a \ + && gem install bundler --version "=2.1.4"\ + && chmod -R 777 /usr/local/.rbenv/versions \ + && chmod -R 777 /usr/local/.rbenv/version + +RUN eval "$(rbenv init -)" \ + && rbenv global $WEBSITES_LATEST_NODE_VERSION \ + && bundle config --global build.nokogiri -- --use-system-libraries + +# Because Nokogiri tries to build libraries on its own otherwise +ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=true + +# SQL Server gem support +RUN apt-get install -y unixodbc-dev freetds-dev freetds-bin + +# Make temp directory for ruby images +RUN mkdir -p /tmp/bundle +RUN chmod 777 /tmp/bundle