Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruby 2.7 #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions 2.7.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM appsvc/rubybase:2.7.0
LABEL maintainer="Azure App Services Container Images <[email protected]>"

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" ]
1 change: 1 addition & 0 deletions 2.7.0/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This image is in development, not yet a working state. Use 2.3-1 for personal testing.
2 changes: 2 additions & 0 deletions 2.7.0/hostingstart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv=X-UA-Compatible content="IE=edge"><title>Microsoft Azure App Service - Welcome</title> <link rel="SHORTCUT ICON" href="https://c.s-microsoft.com/favicon.ico?v2" type="image/x-icon"/><link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/4.1.1/css/bootstrap.min.css" crossorigin="anonymous"><link rel="stylesheet" type="text/css" href="https://appservice.azureedge.net/css/linux-landing-page/v3/main.css"><script type="text/javascript">window.onload=function(){try{var a=window.location.hostname;if(a.includes(".azurewebsites.net")){a=a.replace(".azurewebsites.net", "")}var b=document.getElementById("depCenterLink");b.setAttribute("href", b.getAttribute("href") + "&sitename=" + a);}catch(d){}}</script></head><body><nav class="navbar navbar-light bg-light"><a class="navbar-brand " href="#"><div class="container pl-4 ml-5"> <img src="https://appservice.azureedge.net/images/linux-landing-page/v3/microsoft_azure_logo.png" width="270" height="108" alt=""> </div></a></nav><div class="container-fluid container-height mr-2"><div class="pt-10 pb-10 mt-10 mb-10 d-xxs-none d-xs-none d-sm-none d-md-none d-lg-block d-xl-block" style="height:20px; width:100%; clear:both;"></div><div class="row"><div class="row col-xs-12 col-sm-12 d-block d-lg-none d-xl-none d-md-block d-sm-block d-xs-block"><div class="text-center"> <img src="https://appservice.azureedge.net/images/linux-landing-page/v3/ruby.svg"> </div></div><div class=" extra-pl-small-scr offset-xl-1 offset-lg-1 offset-md-2 offset-sm-2 offset-xs-4 col-xl-5 col-lg-5 col-md-10 col-sm-11 col-xs-11 div-vertical-center"><div class="container-fluid"><div class="row"><h2>Hey, Ruby developers!</h2> </div><br><div class="row"><h4>Your app service is up and running.</h4> </div><div class="row"><h4>Time to take the next step and deploy your code.</h4> </div><div class="row info-mg-top"><p class=" pl-0 col-md-6 col-sm-12 info-mg-top"> Have your code ready?<br>Use deployment center to get code published from your client or setup continuous deployment.<br><a id='depCenterLink' href="https://go.microsoft.com/fwlink/?linkid=2057852"><button class="btn btn-primary btn-mg-top" type="submit">Deployment Center</button></a></p><p class="pl-0 offset-md-1 col-md-5 col-sm-12 info-mg-top">Don't have your code yet?<br>Follow our quickstart guide and you'll have a full app ready in 5 minutes or less.<br><button onclick="location.href='https://go.microsoft.com/fwlink/?linkid=2083208'" class="btn btn-primary btn-mg-top" type="submit">Quickstart</button></p></div></div></div><div class="col-xl-5 col-lg-5 col-md-12 d-none d-lg-block"><div class="text-center"> <img src="https://appservice.azureedge.net/images/linux-landing-page/v3/ruby.svg"> </div></div><div class="col-xl-1 col-lg-1 col-md-1"></div></div></div><!-- Bootstrap core JavaScript==================================================--><script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.2.1.min.js" crossorigin="anonymous"></script><script src="https://ajax.aspnetcdn.com/ajax/bootstrap/4.1.1/bootstrap.min.js" crossorigin="anonymous"></script></body></html>
26 changes: 26 additions & 0 deletions 2.7.0/init_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
cat >/etc/motd <<EOL
_____
/ _ \ __________ _________ ____
/ /_\ \\___ / | \_ __ \_/ __ \
/ | \/ /| | /| | \/\ ___/
\____|__ /_____ \____/ |__| \___ >
\/ \/ \/
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 "$@"

15 changes: 15 additions & 0 deletions 2.7.0/sshd_config
Original file line number Diff line number Diff line change
@@ -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
116 changes: 116 additions & 0 deletions 2.7.0/startup.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions 2.7.0/staticsite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'webrick'
options = {
:Port => ENV["PORT"].to_i,
:DirectoryIndex => ["hostingstart.html"],
:DocumentRoot => '/opt/startup'
}
WEBrick::HTTPServer.new(options).start
61 changes: 61 additions & 0 deletions base_images/2.7.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM buildpack-deps:jessie-curl
LABEL maintainer="Azure App Services Container Images <[email protected]>"

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