diff --git a/.circleci/Dockerfile b/.circleci/Dockerfile index f71dd2a29..d7e5ffd9f 100644 --- a/.circleci/Dockerfile +++ b/.circleci/Dockerfile @@ -3,45 +3,56 @@ FROM public.ecr.aws/amazonlinux/amazonlinux:2 RUN /usr/bin/amazon-linux-extras install -y \ postgresql11 \ python3.8 -RUN /usr/bin/yum install -y \ - gcc \ - gcc-c++ \ - git \ - make \ - openssl-devel \ - postgresql-devel \ - rpm-build \ - shadow-utils \ - sudo \ - util-linux \ - xorg-x11-server-Xvfb \ - zlib-devel + +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.5.tar.gz https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.5.tar.gz \ + && tar -xzf /tmp/ruby-2.7.5.tar.gz \ + && cd ruby-2.7.5 \ + && ./configure \ + && make -j4 \ + && make install \ + && cd .. \ + && rm -rf ruby-2.7.5 /tmp/ruby-2.7.5.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 -RUN git clone https://github.com/sstephenson/rbenv.git ~/.rbenv -RUN git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build -ENV PATH /home/circleci/.rbenv/shims:/home/circleci/.rbenv/bin:/home/circleci/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -RUN echo 'eval "$(rbenv init -)"' >> ~/.bash_profile && \ - eval "$(rbenv init -)" -RUN rbenv install 2.7.5 && rbenv global 2.7.5 -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 61afe58f4..ab2ff7412 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,6 +7,7 @@ jobs: 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..7bde69972 100755 --- a/.elasticbeanstalk/package.sh +++ b/.elasticbeanstalk/package.sh @@ -32,6 +32,8 @@ PACKAGE="${VERSION}.zip" cp config/database.yml.beanstalk config/database.yml +PYTHON_BIN=${PYTHON_BIN:-python} + .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/Dockerfile b/Dockerfile index d71c84b12..bfcdb8a9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7.5 +FROM public.ecr.aws/docker/library/ruby:2.7.5 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" ]