LoginSignup
4
3

More than 3 years have passed since last update.

Circle Ci jobでRubyとaws cliとnpmとdockerを使う方法

Posted at

これはなに?

Circle Ciを使っていて、色々入ってるimage探したりOrbs使ったりしてみたけど、やっぱり素直にUbuntuに入れて使うのが良いなーって思った時のまとめです。

前提

  • Circle Ci: 2.1
  • AWSの環境変数は埋め込み済み
  • Ci好き

jobsサンプルコード

sample-job: 
    working_directory: ~/app
    docker:
      - image: circleci/ruby:2.5.1-node-browsers # このimageならnpmとrubyが既に入っている
        environment: 
         KANKYOHENSU: kankyohensu #よしなに設定
    steps:
      - checkout
      - setup_remote_docker: # dockerを使う場合はCircle Ciが用意したものを使うので立ち上げる
          docker_layer_caching: true
      # aws cliのinstall
      - run: sudo apt-get update && sudo apt-get install python3-pip groff-base
      - run: sudo pip3 install awscli --ignore-installed six
      # aws cli使えるから色々自動化デキル
      - run: aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
      - run: aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
      # gemのinstallも勿論デキる
      - run: bundle check || bundle install --jobs 4 --retry 3
      # assets:precompileやらnpmやら諸々デキる
      - run: npm install && npm run release
      - run: bundle exec rails assets:precompile
      # 後は煮るなり焼くなり好きにやってくれ

これでCi上で大体の事できる。
AWS上のことならここから自由自在に操作すればよい。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3