Skip to content

Instantly share code, notes, and snippets.

@Faq
Last active November 9, 2024 18:49
Show Gist options
  • Save Faq/e1710c6c5f228ed462bdf0ef4cf6e7e4 to your computer and use it in GitHub Desktop.
Save Faq/e1710c6c5f228ed462bdf0ef4cf6e7e4 to your computer and use it in GitHub Desktop.
FROM rockylinux:9.3
RUN dnf -y install glibc-locale-source glibc-langpack-en &&\
localedef -i en_US -f UTF-8 en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV ruby_majorversion=3.3 ruby_version=3.3.5 openssl_version=3.3.2 git_version=2.18.0 epel_release=9-8.el9
RUN dnf -y update &&\
dnf -y install wget tar make gcc lsof unzip git procps-ng diffutils which
# Install OpenSSL
ENV openssl_path="/usr/local/openssl-${openssl_version}"
RUN dnf -y install perl perl-core openssl-devel &&\
cd /usr/local/src && wget https://www.openssl.org/source/openssl-${openssl_version}.tar.gz &&\
cd /usr/local/src && tar -xzvf openssl-${openssl_version}.tar.gz &&\
cd openssl-${openssl_version} &&\
./config shared --prefix=${openssl_path} --openssldir=${openssl_path} &&\
make &&\
make install &&\
rm /usr/local/src/openssl-${openssl_version}.tar.gz
# Set environment variables for OpenSSL
ENV LD_LIBRARY_PATH=/usr/local/openssl-${openssl_version}/lib
ENV PATH=/usr/local/openssl-${openssl_version}/bin:$PATH
# Enable CRB repository
RUN dnf -y install dnf-plugins-core &&\
dnf config-manager --set-enabled crb
# Install Ruby dependencies
RUN cd /tmp &&\
wget https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/e/epel-release-${epel_release}.noarch.rpm &&\
rpm -Uvh epel-release-${epel_release}.noarch.rpm &&\
dnf -y install readline readline-devel zlib zlib-devel ncurses ncurses-devel glibc-devel tcl-devel gcc-c++ unzip \
openssl-devel curl-devel byacc gdbm-devel ruby-devel ruby-libs rubygems rubygems-devel libyaml-devel libffi-devel patch xz
# Install Ruby
RUN cd /usr/local/src &&\
wget https://cache.ruby-lang.org/pub/ruby/${ruby_majorversion}/ruby-${ruby_version}.tar.gz &&\
tar zxvf ruby-${ruby_version}.tar.gz &&\
cd ruby-${ruby_version} &&\
./configure --disable-install-doc --prefix=/usr/local/ruby-${ruby_version} --enable-shared --with-openssl-dir=/usr/local/openssl-${openssl_version} &&\
make &&\
make install &&\
echo 'PATH=/usr/local/ruby-${ruby_version}/bin:$PATH' >> ~/.bashrc &&\
rm /usr/local/src/ruby-${ruby_version}.tar.gz
# Set environment variables for Ruby
ENV PATH=/usr/local/ruby-${ruby_version}/bin:$PATH
ENV nginx_version=1.26.2 passenger_version=6.0.23 strscan_version=3.1.0
ENV BUNDLER_VERSION=2.5.22 rubygems_version=3.5.22
ENV GEM_HOME=/gems
ENV PATH="$GEM_HOME/bin:$GEM_HOME/bundler/gems/bin:$PATH"
RUN gem install bundler -v ${BUNDLER_VERSION} --force &&\
bundle config set --local path $GEM_HOME &&\
gem update --system ${rubygems_version} &&\
# skip installing gem documentation
echo 'gem: --no-document' >> "$HOME/.gemrc" &&\
gem install strscan -v ${strscan_version} &&\
gem install passenger -v ${passenger_version}
# Symlinc passenger
RUN ln -s $(passenger-config --root) /passenger_root
# Set up various directories and rights
RUN groupadd -f nginx -g 9999 &&\
useradd -r nginx -u 9999 -g 9999 &&\
mkdir -p /var/log/nginx &&\
chown -R nginx:nginx /var/log/nginx &&\
chmod -R 755 /var/log/nginx &&\
mkdir -p /var/run/nginx &&\
chown -R nginx:nginx /var/run/nginx &&\
chmod -R 755 /var/run/nginx &&\
mkdir -p /nginx/{log,pids,cache} && \
chown -R nginx:nginx /nginx && \
chmod -R 755 /nginx && \
mkdir -p /application && \
chown -R nginx:nginx /application && \
chmod -R 755 /application
## Install Nginx
RUN dnf -y install pcre-devel &&\
mkdir -p /etc/nginx &&\
mkdir -p /var/run/nginx &&\
mkdir -p /var/log/nginx &&\
cd /usr/local/src && wget http://nginx.org/download/nginx-${nginx_version}.tar.gz &&\
tar xvfz nginx-${nginx_version}.tar.gz && cd /usr/local/src/nginx-${nginx_version} &&\
./configure \
--user=nginx \
--group=nginx \
--prefix=/opt/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/run/nginx/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/run/nginx/client_body_temp \
--http-proxy-temp-path=/var/run/nginx/proxy_temp \
--without-http_autoindex_module \
--without-http_memcached_module \
--without-http_browser_module \
--without-http_fastcgi_module \
--without-http_scgi_module \
--without-http_split_clients_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_uwsgi_module \
--without-http_referer_module \
--without-http_limit_conn_module \
--without-http_map_module \
--without-http_limit_req_module \
--without-http_geo_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--with-http_v2_module \
--with-openssl=/usr/local/src/openssl-${openssl_version} \
--add-module=$(passenger-config --nginx-addon-dir) &&\
make &&\
make install &&\
rm /usr/local/src/nginx-${nginx_version}.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment