Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CircleCIで docker-compose最強? / docker-compose-up-on-circleci

CircleCIで docker-compose最強? / docker-compose-up-on-circleci

2019-06-26 五反田.rb #37のLT資料です!
『CircleCIで docker-compose最強?』

https://gotanda-rb.connpass.com/event/135422/

WalkerSumida

June 26, 2019
Tweet

More Decks by WalkerSumida

Other Decks in Technology

Transcript

  1. $JSDMF$*Ͱ
    EPDLFSDPNQPTF࠷ڧ
    גࣜձࣾϚπϦΧ/PUJBࣄۀ੹೚ऀ"ZVNV4VNJEB

    View full-size slide

  2. ͋ɺࠓ೔ͷ͓୊͸
    d34QFDςετʹ͍ͭͯd
    ͬͯ͜ͱ͸Θ͔͍ͬͯ·͢

    View full-size slide

  3. גࣜձࣾ
    ϚπϦΧ
    4FOTFT 4'"$3.

    /PUJB &NBJM5SBDLJOH

    3BJMTPS3FBDU
    ΤϯδχΞ
    ઈࢍืूதͰ͢ʂ

    View full-size slide

  4. w େֶߦ͖ͳ͕Β*5ϕϯνϟʔاۀͰ໿೥ؒ༗ঈΠϯλʔϯ
    w 1)1
    .Z42- $BLF1)1 Y
    8PSEQSFTT $ "41
    /&5
    w ౦ࣳ৘ใγεςϜגࣜձࣾͰ೥ؒϔϧεέΞࣄۀʹैࣄ
    w 7#/&5 $ 0SBDMF%BUBCBTF
    w ̍ਓͰىۀ͠Α͏ͱࢼΈΔ͕ࣦഊ
    w 3VCZPO3BJMT 'VFM1)1
    .Z42- "84 "OTJCMF
    w גࣜձࣾϚπϦΧʹΤϯδχΞೋਓ໨Ͱ+PJO
    w 4FOTFTͱ/PUJBΛ։ൃӡ༻
    w 3VCZPO3BJMT "OHVMBS+4 .Z42- "84
    ܦྺ

    View full-size slide

  5. Έͳ͞Μ͸ϩʔΧϧͷ
    ։ൃ؀ڥ͸EPDLFSͰߏங͍ͯ͠·͔͢ʁ

    View full-size slide

  6. ࢲ͸΋͏શͯEPDLFSͰߏங͠
    ͍ͯ·͢

    View full-size slide

  7. mysql:
    image: mysql:5.7
    ports:
    - 3306:3306
    volumes:
    - ./docker/mysql/conf.d:/etc/mysql/conf.d
    - mysql-data:/var/lib/mysql
    environment:
    MYSQL_ROOT_PASSWORD: root
    .Z42-ͷىಈ

    View full-size slide

  8. rails_api:
    tty: true
    stdin_open: true
    build:
    context: .
    dockerfile: Dockerfile
    entrypoint: sh /app/docker/bin/wait_for_mysql.sh sh /app/docker/bin/rails_start.sh
    ports:
    - 3000:3000
    volumes:
    - .:/app
    environment:
    - DB_USERNAME=root
    - DB_PASSWORD=root
    - DB_HOST=mysql
    - DOCKER_HOST=0.0.0.0
    depends_on:
    - mysql
    - redis
    - mongodb
    - dynamodb
    3BJMTͷىಈ

    View full-size slide

  9. $JSDMF$*7͔ΒEPDLFS͕

    View full-size slide

  10. ศརʹͳΓ·ͨ͠ΑͶ

    View full-size slide

  11. ͋Εʁࠓ೔ͷ͓୊͸
    d34QFDςετʹ͍ͭͯd
    Ͱ͸ʁ

    View full-size slide

  12. ҆৺͍ͯͩ͘͠͞ɻ
    ࠷ޙʹग़͖ͯ·͢ɻ

    View full-size slide

  13. EPDLFSDPNQPTF $JSDMF$*ʜ
    ͦ͜Ͱࢥͬͨ

    View full-size slide

  14. ͜ͷϩʔΧϧ։ൃ؀ڥͷ
    EPDLFSDPNQPTFZNMΛ
    $JSDMF$*্Ͱ࢖͑ͨΒ

    View full-size slide

  15. ςετ؀ڥΛҙࣝ͠ͳͯ͘
    Α͘ͳΔͷͰ

    View full-size slide

  16. %9ͷվળʹͳΔͷͰ͸ʁ

    View full-size slide

  17. - run:
    name: Install Docker Compose
    command: |
    curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
    chmod +x ~/docker-compose
    sudo mv ~/docker-compose /usr/local/bin/docker-compose
    EPDLFSDPNQPTFΛΠϯετʔϧ

    View full-size slide

  18. - run:
    name: docker-compose up
    command: |
    set -x
    docker-compose up --build -d
    EPDLFSDPNQPTFVQ

    View full-size slide

  19. - run:
    name: docker-compose stop
    command: |
    set -x
    docker-compose stop
    EPDLFSDPNQPTFTUPQ

    View full-size slide

  20. - run:
    name: docker-compose up
    command: |
    set -x
    docker-compose up --build -d
    EPDLFSDPNQPTFVQ

    View full-size slide

  21. - run:
    name: test
    command: |
    mkdir /tmp/test-results
    TEST_FILES="$(circleci tests glob 'spec/**/*_spec.rb' | circleci tests split --split-by=timings)"
    docker-compose exec rails_api bin/rspec --format progress \
    --format RspecJunitFormatter \
    --out /tmp/test-results/rspec.xml \
    $TEST_FILES
    ΍ͬͱͰ͖ͯͨ3TQFD

    View full-size slide

  22. w IUUQTHJUIVCDPNXBMLFSTVNJEBSBJMTBQJGPSOVYUKTQVMM
    αϯϓϧ͸ͪ͜Β

    View full-size slide

  23. Ҏ্ɺ34QFDςετʹ͍ͭͯɺͰͨ͠ʂ
    ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ

    View full-size slide