From 826c3cf205634f87fbf9dce06aa65b41f47ad600 Mon Sep 17 00:00:00 2001 From: Eito Katagiri Date: Sat, 11 Dec 2021 00:29:50 +0900 Subject: [PATCH] update ruby to 2.7.6 --- .circleci/Dockerfile | 60 ++++++++++++------- .circleci/config.yml | 9 +-- .circleci/docker-entrypoint.sh | 0 .elasticbeanstalk/package.sh | 4 +- .../postdeploy/01_set_proxy_timeout_value.sh | 8 +++ .../02_create_public_system_directory.sh | 6 -- .ruby-version | 2 +- Dockerfile | 3 +- Gemfile | 2 +- Gemfile.lock | 2 +- 10 files changed, 57 insertions(+), 39 deletions(-) mode change 100644 => 100755 .circleci/docker-entrypoint.sh create mode 100755 .platform/hooks/postdeploy/01_set_proxy_timeout_value.sh delete mode 100755 .platform/hooks/predeploy/02_create_public_system_directory.sh diff --git a/.circleci/Dockerfile b/.circleci/Dockerfile index a8f712ae4..4cba30634 100644 --- a/.circleci/Dockerfile +++ b/.circleci/Dockerfile @@ -2,43 +2,57 @@ FROM public.ecr.aws/amazonlinux/amazonlinux:2 RUN /usr/bin/amazon-linux-extras install -y \ postgresql11 \ - python3.8 \ - ruby2.6 -RUN /usr/bin/yum install -y \ - gcc \ - gcc-c++ \ - git \ - make \ - postgresql-devel \ - rpm-build \ - ruby-devel \ - rubygem-io-console \ - shadow-utils \ - sudo \ - util-linux \ - xorg-x11-server-Xvfb \ - zlib-devel + python3.8 + +RUN /usr/bin/yum install -y deltarpm && \ + /usr/bin/yum update -y && \ + /usr/bin/yum install -y \ + gcc \ + gcc-c++ \ + git \ + libffi-devel \ + libpq-devel \ + make \ + openssl-devel \ + python38-devel \ + readline-devel \ + rpm-build \ + shadow-utils \ + sudo \ + util-linux \ + xorg-x11-server-Xvfb \ + zlib-devel + RUN curl -sSL -o /tmp/dockerize.tgz https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-linux-amd64-v0.6.1.tar.gz && \ tar -xzf /tmp/dockerize.tgz -C /usr/local/bin && \ rm /tmp/dockerize.tgz + +RUN curl -sSL -o /tmp/ruby-2.7.6.tar.gz https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.gz \ + && tar -xzf /tmp/ruby-2.7.6.tar.gz \ + && cd ruby-2.7.6 \ + && ./configure \ + && make -j4 \ + && make install \ + && cd .. \ + && rm -rf ruby-2.7.6 /tmp/ruby-2.7.6.tar.gz + RUN curl -sLO https://rpm.nodesource.com/setup_14.x && \ bash setup_14.x && \ rm setup_14.x && \ yum install -y nodejs + RUN curl -sLO https://dl.yarnpkg.com/rpm/yarn.repo && \ mv yarn.repo /etc/yum.repos.d/ && \ yum install -y yarn + ADD ./docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh -RUN rm /usr/bin/python && ln -s /usr/bin/python3.8 /usr/bin/python +RUN python3.8 -m pip install cryptography==3.3.2 awscli awsebcli -RUN /usr/sbin/adduser -m circleci&& usermod -aG wheel circleci -RUN /usr/bin/sed -i -e "s/^# %wheel/%wheel/" /etc/sudoers +# RUN /usr/sbin/adduser -m circleci&& usermod -aG wheel circleci +# RUN /usr/bin/sed -i -e "s/^# %wheel/%wheel/" /etc/sudoers -USER circleci -ENV PATH /home/circleci/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -RUN sudo /usr/bin/pip3.8 install --upgrade pip -RUN sudo /usr/local/bin/pip3.8 install awscli awsebcli +# USER circleci ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/.circleci/config.yml b/.circleci/config.yml index c3e6144c2..7a06d10b0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,11 +2,12 @@ version: 2 jobs: build: docker: - - image: safecast/api-build:2.6.8-amazonlinux2 + - image: safecast/api-build:2.7.6-amazonlinux2 environment: RAILS_ENV: test AWS_DEFAULT_REGION: us-west-2 EB_APP_NAME: api + PYTHON_BIN: python3.8 - image: mdillon/postgis:11 environment: POSTGRES_USER: safecast @@ -19,15 +20,15 @@ jobs: - checkout - restore_cache: keys: - - v4-safecastapi-{{ checksum "Gemfile.lock" }} - - v4-safecastapi- + - v5-safecastapi-{{ checksum "Gemfile.lock" }} + - v5-safecastapi- - run: name: Bundle Install command: | gem install bundler -v 2.2.29 bundle install --path vendor/bundle --jobs 2 --retry 3 - save_cache: - key: v4-safecastapi-{{ checksum "Gemfile.lock" }} + key: v5-safecastapi-{{ checksum "Gemfile.lock" }} paths: - vendor/bundle - run: diff --git a/.circleci/docker-entrypoint.sh b/.circleci/docker-entrypoint.sh old mode 100644 new mode 100755 diff --git a/.elasticbeanstalk/package.sh b/.elasticbeanstalk/package.sh index 89fc59efe..29f4ede98 100755 --- a/.elasticbeanstalk/package.sh +++ b/.elasticbeanstalk/package.sh @@ -32,7 +32,9 @@ PACKAGE="${VERSION}.zip" cp config/database.yml.beanstalk config/database.yml -.elasticbeanstalk/package.py "${PACKAGE}" +PYTHON_BIN=${PYTHON_BIN:-python} + +${PYTHON_BIN} .elasticbeanstalk/package.py "${PACKAGE}" aws s3 cp --no-progress ".elasticbeanstalk/app_versions/${PACKAGE}" "s3://${S3_BUCKET_NAME}/${EB_APP_NAME}/" diff --git a/.platform/hooks/postdeploy/01_set_proxy_timeout_value.sh b/.platform/hooks/postdeploy/01_set_proxy_timeout_value.sh new file mode 100755 index 000000000..b79833526 --- /dev/null +++ b/.platform/hooks/postdeploy/01_set_proxy_timeout_value.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +VISIBILITY_TIMEOUT=$(/opt/elasticbeanstalk/bin/get-config meta -k sqsdconfig | jq -r .visibility_timeout) +if [ -n "$VISIBILITY_TIMEOUT" ]; then + echo "proxy_read_timeout ${VISIBILITY_TIMEOUT}s;" > /etc/nginx/conf.d/worker.conf +else + echo "proxy_read_timeout 600s;" > /etc/nginx/conf.d/web.conf +fi diff --git a/.platform/hooks/predeploy/02_create_public_system_directory.sh b/.platform/hooks/predeploy/02_create_public_system_directory.sh deleted file mode 100755 index 303fa3b4e..000000000 --- a/.platform/hooks/predeploy/02_create_public_system_directory.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -PUBLIC_SYSTEM_DIR=/var/app/staging/public/system -if [ ! -e $PUBLIC_SYSTEM_DIR ]; then - mkdir -p $PUBLIC_SYSTEM_DIR -fi diff --git a/.ruby-version b/.ruby-version index 743af5e12..49cdd668e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.8 +2.7.6 diff --git a/Dockerfile b/Dockerfile index a52b076aa..3dc790aa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.6.8 +FROM public.ecr.aws/docker/library/ruby:2.7.6 RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" >> /etc/apt/sources.list.d/pgdg.list RUN curl -q https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - @@ -13,7 +13,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /src ADD Gemfile Gemfile.lock .ruby-version /src/ -RUN gem install bundler -v 2.2.29 # Ruby 2.6 running on 64bit Amazon Linux 2/3.3.7 RUN bundle install --jobs=4 --retry=3 CMD [ "bundle", "exec", "rails", "server", "-b", "0.0.0.0" ] diff --git a/Gemfile b/Gemfile index c4a8e4631..43ecc76f3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -ruby '2.6.8' +ruby '2.7.6' gem 'rails', '~> 6.0.3.7' diff --git a/Gemfile.lock b/Gemfile.lock index 5ab6d9951..ac49f7a2b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -582,7 +582,7 @@ DEPENDENCIES webmock RUBY VERSION - ruby 2.6.8-p205 + ruby 2.7.6-p219 BUNDLED WITH 2.2.29