본문 바로가기

build5

Build Context - 출처: https://docs.docker.com/build/building/context/ Build context docs.docker.com Build context "docker build"는 Dockerfile과 context로 부터 docker image를 build 하는 명령어다. Build context는 build 명령어에서 제일 마지막에 인자에 해당한다. docker build [OPTIONS] PATH | URL | - ^^^^^^^^^^^^^^ 명령어를 보면 짐작할 수 있듯이 build를 위한 context로 아래와 같은 입력들을 전달할 수 있다. local directory의 상대경로나 절대경로 원격 Git repository, tarball, plain-text 파일의 주소 .. 2023. 8. 12.
Docker - build arguments - 출처: https://docs.docker.com/build/guide/build-args/ - Change runtime versions 일반적으로 build 인자를 실질적으로 사용하는 경우는 build stage 에서 runtime version을 지정하는 경우이다. 우리가 작성한 Dockerfile은 golang:1.20-alpine 을 기본 image로 사용하고 있다. 만약 다른 Go version을 사용해서 application을 build 하고 싶다면 어떻게 해야할까? 가장 직관적으로는 Dockerfile 내의 version을 갱신해주면 되지만 이런 방법은 매우 불편하고 비효율적이다. # syntax=docker/dockerfile:1 ARG GO_VERSION=1.20 FROM golan.. 2023. 6. 28.
Docker - Multi stage - 출처: https://docs.docker.com/build/guide/multi-stage/ - Multi stage Docker는 multi-stage라는 기능을 제공한다. 왜 Multi-stage를 사용해야할까? build를 병렬로 수행할 수 있다. 마지막 이미지 크기를 더 작게 만들 수 있다. - Add stages 그렇다면 build stage란 무엇인가? build stage는 Dockerfile에서 FROM 지시어에 해당한다. 이전 Section(https://ocwokocw.tistory.com/302) 의 Dockerfile은 단일 stage에 해당하는데 최종 image가 프로그램을 컴파일하는데 사용되는 resource 때문에 용량이 큰것을 확인할 수 있다. % docker image.. 2023. 6. 20.
Docker image and layer - 출처: https://docs.docker.com/build/guide/intro/ Docker image에 대한 전반적인 이해를 위해서 docker 공식 guide document 중 Build with docker 의 내용이 좋아보여 차근차근 따라해보려고 한다. - Introduction Guide 문서 에서는 Go project와 Dockerfile을 통해서 설명하고 있다. (Go에 대한 지식은 필요 없다고 말하고 있다.) Docker desktop이나 Docker engine은 설치되어 있다고 가정한다. 예제 환경 구성을 위해 Github example repository(https://github.com/dockersamples/buildme.git)를 clone 한다. clone후 폴더 구.. 2023. 6. 18.
Go - compile 과 install 참조: https://go.dev/doc/tutorial/compile-install - 개요 이번에는 go 의 새로운 명령어 2 가지를 배워보도록 한다. go run 명령어는 프로그램을 자주 변경할 때 프로그램을 compile 하고 실행 시키는데 유용한 단축 명령어(shortcut)지만 실행 가능한 binary 를 생성하지는 않는다. go build 명령어는 package 를 compile 하지만 결과물을 설치하지는 않는다. go install 은 package 를 compile 하고 설치한다. - build hello directory 에서 go build 명령어를 실행하여 코드를 compile 하고 실행가능한 파일을 생성한다. go build ls go.mod hello hello.go ./hell.. 2021. 11. 28.