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

Base Image Journey 2018

stormcat24
October 09, 2018

Base Image Journey 2018

Container Build Meetup #1

stormcat24

October 09, 2018
Tweet

More Decks by stormcat24

Other Decks in Programming

Transcript

  1. "MQJOF-JOVY.FFUVQ   ެࣜΠϝʔδ "MQJOFԽൃද Ϗοάόϯ CVTZCPY "MQJOF ྲྀߦ શͯͷىݯ͸

    TDSBUDI͔Β   %PDLFS ᴈ໌ظ NVMUJTUBHF CVJME %PDLFS ॏ͞ͳͲ ؾʹ͠ͳ͍ ࣌୅   %PDLFS ྲྀߦظ ೶ߞཱ֬ ੴثͷൃ໌ ෢ՈͷఱԼ ͸͡·Δ మ๒఻དྷ ೆ๺ே࣌୅ Ԡਔͷཚ ૽ཚ͋Δ΋ ҆ఆظ΁ େࡔͷਞ ๛ਉ໓๢ 36/࡟ݮ ݮྔख๏ ऴᖼ EJTUSPMFTT ৽ͨͳ ϕʔεΠϝʔδ ࣌୅΁ େ੓ไؐ HMJCDͷཚ ೥දతͳΞϨ #VJME,JU ࠇધ ऻདྷ
  2. "MQJOF-JOVY ‣ #VTZCPYϕʔεͰɺ͜Ε΋૊ΈࠐΈܥ޲͚ ‣ BMQJOFͷαΠζ໿.# ‣ ύοέʔδϚωʔδϟBQL ‣ ඪ४$ϥΠϒϥϦ͸NVTM ‣

    ೥ʹɺඪ४%PDLFSΠϝʔδͷϕʔεΠϝʔδͱͯ͠ ࠾༻͞ΕΔ ‣ Ҏޙɺܰྔ͞ͱѻ͍΍͔͢͞Β޿·Δ
  3. "MQJOFͰͷϏϧυ FROM alpine:3.7 RUN apk add --no-cache wget RUN wget

    https://github.com/progrium/entrykit/releases/download/ v0.4.0/entrykit_0.4.0_Linux_x86_64.tgz RUN tar -xvzf entrykit_0.4.0_Linux_x86_64.tgz RUN rm entrykit_0.4.0_Linux_x86_64.tgz RUN mv entrykit /bin/entrykit RUN chmod +x /bin/entrykit RUN entrykit --symlink
  4. 36/ͷ਺ΛݮΒ࣌͢୅ FROM alpine:3.7 RUN apk add --no-cache wget && \

    wget https://github.com/progrium/entrykit/releases/download/ v0.4.0/entrykit_0.4.0_Linux_x86_64.tgz && \ tar -xvzf entrykit_0.4.0_Linux_x86_64.tgz && \ rm entrykit_0.4.0_Linux_x86_64.tgz && \ mv entrykit /bin/entrykit && \ chmod +x /bin/entrykit && \ entrykit --symlink 36/ͷճ਺͚ͩΠϝʔδϨΠϠʔ͕ੵΈॏͳΔ ྦ͙·͍͠Πϝʔδݮྔ࣌୅΁ಥೖ ˞Մಡੑ௿Լͱ࿑ྗ૿
  5. NVMUJTUBHFCVJME౸དྷ FROM alpine:3.7 AS build RUN apk add --no-cache wget

    RUN wget https://github.com/progrium/entrykit/releases/download/ v0.4.0/entrykit_0.4.0_Linux_x86_64.tgz RUN tar -xvzf entrykit_0.4.0_Linux_x86_64.tgz RUN mv entrykit /bin/entrykit FROM alpine:3.7 COPY --from=build /bin/entrykit /bin/ RUN chmod +x /bin/entrykit RUN entrykit —symlink ‏ΞϓϦέʔγϣϯͷ഑ஔ͚ͩʹઐ೦Ͱ͖Δ ‏Ϗϧυ࣌ͷ࢈ഇॲཧ͕ෆཁ
  6. FHEJTUSPMFTT (PMBOH FROM golang:1.10 as build-env WORKDIR /go/src/app ADD .

    /go/src/app RUN go-wrapper download RUN go-wrapper install FROM gcr.io/distroless/base COPY --from=build-env /go/bin/app / CMD ["/app"] ‏(PͷެࣜΠϝʔδͰϏϧυ ‏NVMUJTUBUFCVJME
  7. EFCVHJNBHF ‣ EJTUSPMFTTʹ͸TI͕ແ͍ ‣ ίϯςφͷதΛ८ճ͚ͨ͠Ε͹ɺEFCVHΠϝʔδΛ࢖͏ ‣ CVTZCPYͷTI͕࢖͑Δ $ docker container

    run -ti --entrypoint=sh gcr.io/distroless/base:debug / # ls -l total 40 drwxr-xr-x 2 root root 12288 Jan 1 1970 busybox drwxr-xr-x 5 root root 360 Oct 9 02:51 dev drwxr-xr-x 5 root root 4096 Oct 9 02:51 etc drwx------ 2 root root 4096 Oct 9 02:51 home ...
  8. CVJMEHSBEMF jib.to.image = 'registry.hub.docker.com/stormcat24/hellojib:latest' jib { from { image =

    'gcr.io/distroless/java' credHelper = 'osxkeychain' } to { image = 'registry.hub.docker.com/stormcat24/hellojib:latest' credHelper = 'osxkeychain' auth { username = dockerUsername password = dockerPassword } } container { jvmFlags = ['-Djava.security.egd=file:/dev/./urandom', '-Duser.timezone=GMT+08', '-Xdebug'] mainClass = 'com.example.jib.JibApplication' args = ['some args'] ports = ['8080'] }
  9. +JCͰϏϧυ $ ./gradlew jib warning: Base image 'gcr.io/distroless/java' does not

    use a specific image digest - build may not be reproducible Containerizing application to stormcat24/hellojib... Retrieving registry credentials for registry.hub.docker.com... Getting base image gcr.io/distroless/java... … Built and pushed image as stormcat24/hellojib BUILD SUCCESSFUL in 3s $ docker image ls --filter "reference=stormcat24/hellojib" REPOSITORY TAG IMAGE ID CREATED SIZE stormcat24/hellojib latest 66a7c02acbdf 48 years ago 119MB ‐೥લʹͳͬͯͯ૲