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

Container Build Talk

orisano
July 25, 2019

Container Build Talk

orisano

July 25, 2019
Tweet

More Decks by orisano

Other Decks in Programming

Transcript

  1. EPDLFSDMJ EPDLFSE HTTP Mac LinuxKit $ docker build [build context]

    directoryҎԼΛ.dockerignore Λߟྀͯ͠tarʹ͢Δ
  2. EPDLFSDMJ EPDLFSE HTTP Mac LinuxKit $ docker build [build context]

    directoryҎԼΛ.dockerignore Λߟྀͯ͠tarʹ͢Δ tar
  3. Stage FROM image [AS stage] RUN apk add ca-certificates COPY

    package.json . COPY package-lock.json . ENV NODE_ENV=production RUN npm ci COPY . . RUN npm run build
  4. ϕʔεΠϝʔδ $01:"%% ϕʔεΠϝʔδ 36/ $01:"%% 36/ $01:"%% 36/ $01:"%% ίϐʔͨ͠಺༰Ͱ

    ίϚϯυ͕มΘΔ ڞ௨ͷ਌Λ࣋ͭಉ͡ίϚϯυͷΠϝʔδͰ ࠷৽ͷ΋ͷΛΩϟογϡͱͯ͠༻͍Δ
  5. ϕʔεΠϝʔδ $01:"%% ϕʔεΠϝʔδ 36/ $01:"%% 36/ $01:"%% 36/ $01:"%% ίϐʔͨ͠಺༰Ͱ

    ίϚϯυ͕มΘΔ ڞ௨ͷ਌Λ࣋ͭಉ͡ίϚϯυͷΠϝʔδͰ ࠷৽ͷ΋ͷΛΩϟογϡͱͯ͠༻͍Δ Dockerd
  6. docker pull application:build-base-cache || true docker build -t application:build-base-cache --target=build-base

    --cache- from=application:build-base-cache . docker pull application:base-cache || true docker build -t application:base-cache --target=base --cache-from=application:build-base- cache,application:base-cache . docker pull application:app-build-cache || true docker build -t application:app-build-cache --target=app-build --cache- from=application:build-base-cache,application:base-cache,application:app-build-cache . docker pull application:app-base-cache || true docker build -t application:app-base-cache --target=app-base --cache- from=application:build-base-cache,application:base-cache,application:app-build- cache,application:app-base-cache . docker pull application:application-cache || true docker build -t application:application-cache --target=application --cache- from=application:build-base-cache,application:base-cache,application:app-build- cache,application:app-base-cache,application:application-cache .
  7. Stage FROM image [AS stage] RUN apk add ca-certificates COPY

    package.json . COPY package-lock.json . ENV NODE_ENV=production RUN npm ci #!COMMIT COPY . . RUN npm run build
  8. Stage FROM image [AS stage] RUN apk add ca-certificates COPY

    package.json . COPY package-lock.json . ENV NODE_ENV=production RUN npm ci #!COMMIT COPY . . RUN npm run build