admin管理员组文章数量:1122832
Rails codepipe line doest work.
I set set SECRET_KEY_BASE
RAILS_MASTER_KEY
value on manifest.yml .
and more , i hardcode the value on Doceker file.
but SECRET_KEY_BASE is not transffered correctly thus , code pipeline is failed.
manifest.yml
variables: # Pass environment variables as key value pairs.
LOG_LEVEL: debug
RAILS_ENV: production
BACKEND_URL:
RAILS_LOG_TO_STDOUT: enabled
BUNDLE_FORCE_RUBY_PLATFORM: 1
secrets:
AWS_ACCESS_KEY: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/aws_access_key
AWS_SECRET_KEY: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/aws_secret_key
AWS_S3_BUCKET: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/aws_s3_bucket
★★ --> RAILS_MASTER_KEY: /copilot/${COPILOT_APPLICATION_NAME}/
${COPILOT_ENVIRONMENT_NAME}/secrets/rails_master_key
REDIS_URL: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/redis_url
★★ --> SECRET_KEY_BASE: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/secret_key_base
Dockerfile is like this . i maganged to work
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(16 bytes is hardcoded)
is generated secret = OpenSSL::Digest::SHA256.digest(secret_key_base)[0, 16]
this command and i hard-code it also.
RUN SECRET_KEY_BASE="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" bundle exec rails assets:precompile RAILS_ENV=production
at Dockerfile at line #38
#1 FROM ruby:3.2.6 AS base
#2 # Declare build arguments
#3 ARG RAILS_MASTER_KEY
#4 # Set Rails environment variables
#5 ENV RAILS_MASTER_KEY=${RAILS_MASTER_KEY}
#6 # Install necessary packages, including Node.js and npm
#7 RUN apt-get update -qq && apt-get install -y build-essential graphviz libxml2-dev libxslt1-dev and so on
#8 # Create the nginx user (this line is commented out)
#9 #RUN adduser --system --no-create-home --shell /bin/false --group --disabled-login nginx
#10 # Install ffi and nokogiri with platform-specific flags to avoid building from source
#11 RUN gem install ffi -v 1.17.0 --platform x86_64-linux-gnu
#12 RUN gem install nokogiri -v 1.16.6 --platform x86_64-linux
#13 # Configure system libraries for nokogiri installation
#14 RUN bundle config build.nokogiri --use-system-libraries
#15 # Configure Ruby platform for gem builds
#16 RUN bundle config set --global force_ruby_platform true
#17 # Create the application directory and set it as the working directory
#18 RUN mkdir /gramstep
#19 WORKDIR /gramstep
#20 # Copy Gemfile and Gemfile.lock for dependency installation
#21 COPY Gemfile /gramstep/Gemfile
#22 COPY Gemfile.lock /gramstep/Gemfile.lock
#23 # Install bundler and project dependencies
#24 RUN gem install bundler -v 2.5.16 && bundle install --jobs 4 --verbose
#25 # Copy nginx configuration
#26 COPY gramstep.conf /etc/nginx/sites-enabled/gramstep.conf
#27 # Copy JavaScript package files and install dependencies
#28 COPY package.json /gramstep/package.json
#29 COPY yarn.lock /gramstep/yarn.lock
#30 RUN yarn install --frozen-lockfile
#31 # Copy application source code
#32 COPY . /gramstep
#33 # Ensure the development script is executable
#34 RUN chmod +x ./bin/dev
#35 # Build JavaScript assets
#36 RUN yarn build
# --------- this is problematic !!!!!!!!--------
#37 # Precompile Rails assets in production mode
#38 RUN SECRET_KEY_BASE="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" bundle exec rails assets:precompile RAILS_ENV=production
# --------- this is problematic !!!!!!!!--------
#39 # Copy Unicorn configuration
#40 COPY config/unicorn.rb config/unicorn.rb
#41 # Debugging step: Verify that RAILS_MASTER_KEY is correctly set
#42 RUN echo "RAILS_MASTER_KEY is $RAILS_MASTER_KEY"
#43 # Copy the entrypoint script and make it executable
#44 COPY entrypoint.sh /usr/bin/
#45 RUN chmod +x /usr/bin/entrypoint.sh
#46 # Set the entrypoint for the container
#47 ENTRYPOINT ["entrypoint.sh"]
#48 # Expose port 80 for the application
#49 EXPOSE 80
#50 # Start nginx in the foreground
#51 CMD ["nginx", "-g", "daemon off;"]
codebuild logs says like this
#25 [21/25] RUN SECRET_KEY_BASE="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" bundle exec rails assets:precompile RAILS_ENV=production
#25 4.831 "@ environment.rb"
#25 4.831 {"RAILS_MASTER_KEY"=>"$RAILS_MASTER_KEY", "HOME"=>"/root", "BUNDLE_APP_CONFIG"=>"/usr/local/bundle", "RUBY_DOWNLOAD_URL"=>".2/ruby-3.2.6.tar.xz", "RUBY_VERSION"=>"3.2.6", "PATH"=>"/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "LANG"=>"C.UTF-8", "GEM_HOME"=>"/usr/local/bundle", "SECRET_KEY_BASE"=>"********************************", "RUBY_DOWNLOAD_SHA256"=>"671134022238c2c4a9d79dc7d1e58c909634197617901d25863642f735a27ecb", "PWD"=>"/***", "BUNDLE_SILENCE_ROOT_WARNING"=>"1", "BUNDLER_ORIG_BUNDLE_BIN_PATH"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_BUNDLE_GEMFILE"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_BUNDLER_VERSION"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_BUNDLER_SETUP"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_GEM_HOME"=>"/usr/local/bundle", "BUNDLER_ORIG_GEM_PATH"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_MANPATH"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_PATH"=>"/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "BUNDLER_ORIG_RB_USER_INSTALL"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_RUBYLIB"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLER_ORIG_RUBYOPT"=>"BUNDLER_ENVIRONMENT_PRESERVER_INTENTIONALLY_NIL", "BUNDLE_BIN_PATH"=>"/usr/local/bundle/gems/bundler-2.5.16/exe/bundle", "BUNDLE_GEMFILE"=>"/***/Gemfile", "BUNDLER_VERSION"=>"2.5.16", "BUNDLER_SETUP"=>"/usr/local/bundle/gems/bundler-2.5.16/lib/bundler/setup", "RUBYOPT"=>"-r/usr/local/bundle/gems/bundler-2.5.16/lib/bundler/setup", "RUBYLIB"=>"/usr/local/bundle/gems/bundler-2.5.16/lib", "MANPATH"=>"/usr/local/bundle/gems/unicorn-6.1.0/man", "RAILS_ENV"=>"production"}
#25 4.968 rails aborted!
#25 4.968 ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage)
#25 4.968 /***/config/environment.rb:7:in `<main>'
#25 4.968
#25 4.968 Caused by:
#25 4.969 ArgumentError: key must be 16 bytes (ArgumentError)
#25 4.969
#25 4.969 cipher.key = @secret
#25 4.969 ^^^^^^^
#25 4.969 /***/config/environment.rb:7:in `<main>'
#25 4.969 Tasks: TOP => environment
#25 4.969 (See full trace by running task with --trace)
#25 ERROR: process "/bin/sh -c SECRET_KEY_BASE=\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" bundle exec rails assets:precompile RAILS_ENV=production" did not complete successfully: exit code: 1
------
> [21/25] RUN SECRET_KEY_BASE="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" bundle exec rails assets:precompile RAILS_ENV=production:
4.968 /***/config/environment.rb:7:in `<main>'
4.968
4.968 Caused by:
4.969 ArgumentError: key must be 16 bytes (ArgumentError)
4.969
4.969 cipher.key = @secret
4.969 ^^^^^^^
4.969 /***/config/environment.rb:7:in `<main>'
4.969 Tasks: TOP => environment
4.969 (See full trace by running task with --trace)
------
Dockerfile.prod:40
--------------------
38 | RUN echo "SECRET_KEY_BASE is $SECRET_KEY_BASE"
39 | RUN echo "RAILS_MASTER_KEY is $RAILS_MASTER_KEY"
40 | >>> RUN SECRET_KEY_BASE="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" bundle exec rails assets:precompile RAILS_ENV=production
41 |
42 | # Unicornの設定
--------------------
本文标签: dockerat rails code pipeline on AWS RAILSMASTERKEY variable doesnt be assigned valueStack Overflow
版权声明:本文标题:docker - at rails code pipeline on AWS RAILS_MASTER_KEY variable doesnt be assigned value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299465a1930462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论