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

AWSでもBuildpacksを使ってDockerfileレスに出来るのか!?/can-i-...

tomoki10
February 16, 2024

 AWSでもBuildpacksを使ってDockerfileレスに出来るのか!?/can-i-use-buildpacks-to-go-dockerfile-less-in-aws

tomoki10

February 16, 2024
Tweet

More Decks by tomoki10

Other Decks in Technology

Transcript

  1. ίϯςφηΩϡϦςΟͷ֓ཁ  ࠓ೔͸ίίͷ࿩ʂ &$4 'BSHBUF &$3 &$44FSWJDF5BTLͳͲ %PDLFSGJMF 71$ͳͲ /FUXPSL

    *NBHF 3FHJTUSZ $POUBJOFS 0SDIFTUSBUPS )PTU04 $POUBJOFS3VOUJNF "QQMJDBUJPO "84 *".
  2. %PDLFSpMFΛॻ͘ϕετϓϥΫςΟε  w Ұ࣌తͳίϯςφΛ࡞੒ w ϏϧυίϯςΫετͷཧղ w ඪ४ೖྗΛ௨ͯ͠%PDLFSpMFΛ ύΠϓ w

    EPDLFSJHOPSFͰআ֎ w ϚϧνεςʔδɾϏϧυΛ࢖͏ w ෆཁͳύοέʔδͷΠϯετʔϧ ېࢭ w ΞϓϦέʔγϣϯΛ੾Γ཭͢ w ϨΠϠͷ਺Λ࠷খʹ w ෳ਺ߦʹΘͨΔҾ਺͸ฒͼΛద੾ ʹ w ϏϧυɾΩϟογϡͷ׆༻ IUUQTEPDTEPDLFSKQEFWFMPQEFWFMPQJNBHFTEPDLFSpMF@CFTUQSBDUJDFTIUNM ଞʹ΋ҙࣝ͢΂͖͜ͱ͕ଟ਺
  3. %PDLFSpMFΛॻ͘ϕετϓϥΫςΟε  w Ұ࣌తͳίϯςφΛ࡞੒ w ϏϧυίϯςΫετͷཧղ w ඪ४ೖྗΛ௨ͯ͠%PDLFSpMFΛ ύΠϓ w

    EPDLFSJHOPSFͰআ֎ w ϚϧνεςʔδɾϏϧυΛ࢖͏ w ෆཁͳύοέʔδͷΠϯετʔϧ ېࢭ w ΞϓϦέʔγϣϯΛ੾Γ཭͢ w ϨΠϠͷ਺Λ࠷খʹ w ෳ਺ߦʹΘͨΔҾ਺͸ฒͼΛద੾ ʹ w ϏϧυɾΩϟογϡͷ׆༻ IUUQTEPDTEPDLFSKQEFWFMPQEFWFMPQJNBHFTEPDLFSpMF@CFTUQSBDUJDFTIUNM ଞʹ΋ҙࣝ͢΂͖͜ͱ͕ଟ਺ ΍Δ͜ͱ͕ɾɾ ΍Δ͜ͱ͕ଟ͍ɾɾʂʂ
  4. %PDLFSpMFͱ$/#ͷҧ͍  %PDLFSpMFͷੈք 4PVSDF $PEF #VJMEQBDLT 1BDL$-* $POUBJOFS *NBHF ࡞੒

    $/#ͷੈքʢཧ૝ʣ 4PVSDF $PEF ಡΈऔΓ %PDLFSpMF ࡞੒º $POUBJOFS *NBHF ࡞੒ ಡΈऔΓ ඞཁϦιʔε Λղੳ
  5. BuildpacksͷଞͷΫϥ΢υͰͷѻ͍  w (PPHMF$MPVEͷ৔߹ w $/#ͷ࢓༷Λ࣮૷͠ɺ(PPHMF$MPVEͷ֤αʔϏεʹσϓϩΠՄೳͳ ίϯςφΛϏϧυͯ͠ߏ੒͢ΔΑ͏ʹઃܭ͞Ε͍ͯΔ˞ w "[VSFͷ৔߹ w

    "[VSF$-*ʹ$/#ͷ1BDL$-*͕૊Έࠐ·Ε͓ͯΓɺ"[VSFίϚϯυͷ தͰ࢖༻͢Δ͜ͱ͕Ͱ͖ΔʢϓϨϏϡʔʣ˞ w "84ͷ৔߹ w ૊ΈࠐΈํͷϒϩάͷΈʢ࣍εϥΠυʣ ˞IUUQTDMPVEHPPHMFDPNEPDTCVJMEQBDLTPWFSWJFX IMKB ˞IUUQTMFBSONJDSPTPGUDPNKBKQB[VSFDPOUBJOFSSFHJTUSZDPOUBJOFSSFHJTUSZUBTLTQBDLCVJME
  6. ࠓճ࡞ͬͨύΠϓϥΠϯશମͷΠϝʔδ  "DUJPOT &$3 'BSHBUF $%, $%, खಈ σϓϩΠ ϦϙδτϦ࡞੒

    NBJO QVTI $/#ͰJNBHF CVJMEQVTI DELEFQMPZ EFQMPZ &$4 *NBHFQVMM
  7. ࠓճ࡞ͬͨύΠϓϥΠϯશମͷΠϝʔδ  "DUJPOT &$3 'BSHBUF $%, $%, खಈ σϓϩΠ ϦϙδτϦ࡞੒

    NBJO QVTI DELEFQMPZ EFQMPZ &$4 *NBHFQVMM $/#ͰJNBHF CVJMEQVTI
  8. (JU)VC"DUJPOTͷઃఆ  env: builder: "paketobuildpacks/builder-jammy-base" pack_version: "0.33.1" ecr_repo_name: "cloudnative-buildpack-sample" jobs:

    build: runs-on: ubuntu-latest permissions: id-token: write contents: read steps: - name: Checkout code uses: actions/checkout@v4 - name: Assume Role uses: aws-actions/configure-aws-credentials@v4 with: aws-region: "ap-northeast-1" role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }} - name: Login to ECR uses: aws-actions/amazon-ecr-login@v2
  9. (JU)VC"DUJPOTͷઃఆ  - name: Set up environment variables run: |

    COMMIT_HASH=$(echo $GITHUB_SHA | cut -c 1-7) ECR_DOMAIN="${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap- northeast-1.amazonaws.com" ECR_REPOSITORY="$ECR_DOMAIN/${{ env.ecr_repo_name }}" IMAGE_TAG="$ECR_REPOSITORY:$COMMIT_HASH" echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV - name: Install pack run: | wget -q https://github.com/buildpacks/pack/releases/download/v$ {{ env.pack_version }}/pack-v${{ env.pack_version }}-linux.tgz -O - | tar -xz chmod +x ./pack - name: Build and push Docker image run: | ./pack build $IMAGE_TAG --no-color --builder ${{ env.builder }} \ --path src/my-app --tag $IMAGE_TAG --publish #VJMEQBDLTΛ࢖ͬͯ*NBHF#VJMEͱ&$3΁ͷQVTI
  10. (JU)VC"DUJPOTͷઃఆ  - name: Setup Node.js 20 uses: actions/setup-node@v4 with:

    node-version: "20" cache: npm - name: Install dependencies run: npm ci - name: ECS Deploy run: | npx cdk deploy "EcsStack" -c imageTag=$COMMIT_HASH $PNNJU)BTIͰ&$3ͷ*NBHFΛࢦఆͯ͠ɺ$%,Ͱ&$4΁σϓϩΠ ஫ҙɿBuildepacksͷAction΋͋ΔΒ͍͠ ɹɹɹʮhttps://github.com/buildpacks/github-actionsʯ
  11. ύΠϓϥΠϯͷσϞ  "DUJPOT &$3 'BSHBUF $%, $%, खಈ σϓϩΠ ϦϙδτϦ࡞੒

    NBJO QVTI $/#ͰJNBHF CVJMEQVTI DELEFQMPZ EFQMPZ &$4 *NBHFQVMM
  12. ಈ͔͢·Ͱͷ஫ҙ఺  w ·ͣ͸ެࣜϦϑΝϨϯεΛͬ͟ͱಡΉ w ࣍ʹCVJMEQBDLTBNQMFT˞Λಈ͔͢͜ͱ͔Β࢝ΊΔͱྑ͍ w (PPHMF$MPVE༻ʹݟ͑Δ͕ॻ͖ํ͸ಉ͡ͳͷͰਅࣅग़དྷΔ w ެࣜͩͱαϯϓϧ͕ͳ͍ͷͰɺมͳͱ͜Ͱ٧·Γ΍͍͢

    w QBDLBHFKTPOͷ%FQFOEFODZΛಡΈऔΔͷͰɺඞཁͳ΋ͷ͸શؚͯΉ Α͏ʹߏ੒͢Δ w ࢖͏#VJMEFS͸QBDLTVHHFTUCVJMEFSTίϚϯυͰઌʹ֬ೝ͢Δ ˞IUUQTHJUIVCDPN(PPHMF$MPVE1MBUGPSNCVJMEQBDLTBNQMFTUSFFNBTUFS
  13. ݸਓతʹࢥ͏ͦ͜·Ͱීٴͯ͠ͳ͍ཧ༝  ஫ҙɿҰ୴ࢼͨ͠ݸਓͷײ૝Ͱ͢ɻۃΊΕ͹มΘΔ͔΋ʁ w ։ൃ؀ڥΛ࡞ΓͮΒ͍ɻ؀ڥઃఆ͕ιʔεʹΑͬͯมΘͬͯ͠·͏ w $16͕"3.ΞʔΩͩͱ޻෉͕ඞཁ˞ Ұ෦ͷػೳ͸ͦͷ··ಈ͘  w

    #VJMEFSͰΧόʔͰ͖ͳ͍৔߹͸मਖ਼͕ඞཁɻ݁ہ͸ཁ$/#৬ਓʁ w $/#पΓͰ͏·͍͔͘ͳ͍৔߹ɺௐ΂ͯ΋৘ใ͕গͳ͍ w 6OJYTPDLFUΛ࡞੒͠ͳ͍ιϑτ 'JODI Ͱ͸࢖͑ͳ͍ʁ˞ w ੬ऑੑͷηΩϡϦςΟΞϥʔτ͕ग़Δ৔߹ͷରԠํ๏ ˞IUUQTHJUIVCDPNENJLVTBQBLFUPBSN ˞IUUQTHJUIVCDPNSVOpODIpODIJTTVFTJTTVFDPNNFOU
  14. $/#ͷੈքʢݱ࣮ʣ  4PVSDF $PEF #VJMEQBDLT 1BDL$-* $POUBJOFS *NBHF ࡞੒ ಡΈऔΓ

    ඞཁϦιʔε Λղੳ ɾ#VJMEFSͷબఆ ɾιʔεΛQBDLDMJ४ڌʹઃఆ ɾ#VJMEFSΧελϜ ɾηΩϡϦςΟରԠ FUDʜ $/#৬ਓ
  15. ·ͱΊ  w "84Ͱ΋#VJMEQBDLTΛ࢖ͬͯ%PDLFSpMFϨεʹग़དྷΔͷ͔  w αϯϓϧϨϕϧͷΞϓϦͳΒͰ͖Δ w ຊ൪ӡ༻ʹ޲͚ͯ͸QBDL΍#VJMEFSͳͲͷ͞ΒͳΔཧղ͕ඞཁ w

    %PDLFSpMFΛॻ͔ͣʹΠϝʔδ͕σϓϩΠͰ͖ΔͷͰָ w $/#ಛ༗ͷઃఆʹ׳ΕΔඞཁ͸͋Δ w ։ൃ؀ڥɺ#VJMEFSɺ੬ऑੑରԠํ๏FUDʜ