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

Docker in CI - Cacoo與Backlog導入Docker的經驗分享

Docker in CI - Cacoo與Backlog導入Docker的經驗分享

Presentation slides at http://containersummit.ithome.com.tw/

株式会社ヌーラボ

December 10, 2015
Tweet

More Decks by 株式会社ヌーラボ

Other Decks in Technology

Transcript

  1. 3VO.VMUJ1SPDFTTFTJO4JOHMF$POUBJOFS # Dockerfile # install package required for test RUN

    apt-get install –y redis-server # Test Configuration in Jenkins $ docker run test-image bach –c “service redis-server start ; ./ gradlew clean test” •  0OMZTJOHMF%PDLFSpMFSFRVJSFE •  3VOUFTUXJUITBNFTFUUJOHJOMPDBM
  2. %FQFOEFODZ$BDIFr)PTU%JSFDUPSZ $ docker run –v ${HOME}/.gradle:/root/.gradle test-image <test command> • 

    )PTUEJSFDUPSZBTDBDIF •  1SPTTIBSFDBDIFXJUIPUIFSKPCT •  $POTQFSNJTTJPOJTTVF
  3. %FQFOEFODZ$BDIFr$BDIFJOBEWBODF # Dockerfile RUN mkdir -p /opt/local/app COPY requirements.txt /opt/local/app/

    WORKDIR /opt/local/app RUN pip install -r requirements.txt COPY . /opt/local/app $ docker build –t test-image . $ docker run test-image <test command> %FQFOEFODZVQEBUF IBQQFOT/05TPPGUFO UIBOBQQMJDBUJPODPEF
  4. %FQFOEFODZ$BDIFr&YUFSOBM$BDIF # Dockerfile RUN mkdir /root/.gradle RUN cd /root/.gradle; curl

    -skL https://s3-ap- northeast-1.amazonaws.com/<cache-bucket>/cache.20151201.tar.gz | tar zxf - •  &YUFSOBMDBDIF •  1SPTGBTUFSJOJUJBMJOTUBMMBUJPO •  $POTNBJOUBJOFYUFSOBMDBDIF
  5. %FQFOEFODZ$BDIF4USBUFHZ )PXUPDBDIF 1SPT $POT 1SPKFDUXFVTF )PTU%JSFDUPSZ 8IFOSVOOJOH UFTU NPVOUIPTU EJSFDUPSZUP

    DPOUBJOFSBOE TUPSFEFQFOEFOU MJCSBSJFTUIFSF 4IBSFMJCSBSJFT BNPOHQSPKFDUT BOETNBMM EFQFOEFODZ DIBOHFEPFTO`U JNQBDUTPNVDI 1FSNJTTJPOJTTVF DPVMEIBQQFOJG UFTUTIPVMECF SVOCZOPOSPPU VTFS +BWB 4DBMB .BWFO  (SBEMF TCU  $BDIFJO BEWBODF $SFBUFMPDBMJNBHF XJUIJOTUBMMJOH EFQFOEFOU MJCSBSJFTCFGPSF UFTUJOH /PQFSNJTTJPO JTTVF 8IFO EFQFOEFODZ DIBOHFE BMM DBDIFXJMMCF DMFBSFE 1FSM 1ZUIPO  OPEFKT &YUFSOBM$BDIF $SFBUFDBDIF BSDIJWFBOETBWF JUUPFYUFSOBM TUPSBHFMJLF4 BOEEPXOMPBEJU XIFOSVOOJOHUFTU 'BTUFSJOJUJBM JOTUBMMBUJPO DPNQBSFEUP MFUUJOHCVJMEUPPM UPSFTPMWF EFQFOEFODJFT  /FFEUPNBJOUBJO FYUFSOBMDBDIF QSPQFSMZUPLFFQ QFSGPSNBODF 4DBMB TCU 
  6. 3FUSJFWF#VJME3FTVMU # Dockerfile WORKDIR /opt/app $ docker run --rm –v

    $(pwd):/opt/app test-image <test command> •  .PVOUXPSLTQBDFUPDPOUBJOFS •  1SPTSFNPWFDPOUBJOFSTPPOBGUFSUFTU •  $POTQFSNJTTJPOJTTVF
  7. 8PSLBSPVOE •  8SJUFSFTVMUUPBWBJMBCMFEJSFDUPSZGPS OPOSPPUVTFS •  $PQZJUUPIPTUEJSFDUPSZCZSPPU # run.sh su test-user

    –c “py.test tests –-junit-xml=/var/tmp/results.xml” cp –p /var/tmp/results.xml . $ docker run --rm –v $(pwd):/opt/app test-image ./run.sh
  8. 8PSLBSPVOE •  $IBOHFPXOFSTIJQUPOPOSPPUVTFS EVSJOHCVJMEUJNF # run.sh chown test-user . su

    test-user –c “py.test tests” chown $1 . $ docker run --rm –v $(pwd):/opt/app test-image ./run.sh $(id -u)
  9. 3FUSJFWF#VJME3FTVMU BMU  # Dockerfile WORKDIR /opt/app COPY . /opt/app

    $ UNIQUE_NAME=“TEST_${GIT_COMMIT}_$(date +%s)” $ docker run --name=${UNIQUE_NAME} test-image <test command> $ docker cp ${UNIQUE_NAME}:/opt/app/build/test-result/ test-result $ docker rm ${UNIQUE_NAME} •  $PQZCVJMESFTVMUGSPNDPOUBJOFS •  1SPTOPQFSNJTTJPOJTTVF •  $POTDPNQMJDBUFE