{"id":331792,"date":"2022-04-11T21:00:31","date_gmt":"2022-04-11T21:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331792"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331792","title":{"rendered":"<span>\u041f\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u043c \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f Dockerfile \u0434\u043b\u044f Go<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5be\/b86\/2a3\/5beb862a395dbb632016cdd91147f39c.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5be\/b86\/2a3\/5beb862a395dbb632016cdd91147f39c.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0432\u0435\u0440\u0445\u0443\u0440\u043e\u0447\u043d\u044b\u0445 \u0447\u0430\u0441\u043e\u0432 \u043a\u0440\u043e\u043f\u043e\u0442\u043b\u0438\u0432\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0435 Hello world \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Go. \u0418 \u0445\u043e\u0442\u044f \u043e\u043d\u043e \u0432\u0441\u0435\u0433\u043e-\u043d\u0430\u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u043e \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u043e \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043c\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0438\u043a \u0431\u044b\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d, \u0447\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u043c\u0435\u043d\u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0435 \u0434\u0435\u0442\u0438\u0449\u0435, \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u044b\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439.<\/p>\n<pre><code>. \u251c\u2500\u2500 go.mod \u2514\u2500\u2500 hello.go<\/code><\/pre>\n<p>\u041a\u043e\u0434 <code>hello.go<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>package mainfunc main() {     println(\"hello world!\") }<\/code><\/pre>\n<p>\u0418 \u0435\u0449\u0435 \u043c\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0438\u043a \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c docker, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0435\u0435.<\/p>\n<h2>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043f\u0440\u043e\u0441\u0438\u0432 \u0441\u0432\u043e\u0438\u0445 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u043e\u0432\u0435\u0442\u044b, \u044f \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 docker, \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0432, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <code>Dockerfile<\/code>:<\/p>\n<pre><code>FROM golang:alpine WORKDIR \/build COPY hello.go . RUN go build -o hello hello.go CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u0418 \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437:<\/p>\n<pre><code>$ docker build -t hello:v1 .<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<pre><code>$ docker run -it --rm hello:v1 ls -l \/build  total 1260  -rwxr-xr-x 1 root root 1281547 Mar 6 15:54 hello  -rw-r--r-- 1 root root 55 Mar 6 14:59 hello.go<\/code><\/pre>\n<p>\u0412\u0435\u0441\u044c \u043c\u043e\u0439 \u043a\u043e\u0434 \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d \u0432 \u043e\u0431\u0440\u0430\u0437. \u041d\u043e \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043b\u043e\u0445\u043e\u0439 \u043a\u043e\u0434, \u0432\u0435\u0434\u044c \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u043a\u0430, \u0442\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0434\u043e \u043c\u043d\u043e\u0439 \u043f\u043e\u0442\u0435\u0448\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0437\u0435\u0440\u043a\u0430\u043b\u0430. \u0413\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u0440\u0430\u0437, \u0442\u0435\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 pull.<\/p>\n<pre><code>$ docker docker images | grep hello  hello v1 2783ee221014 44 minutes ago 314MB<\/code><\/pre>\n<p>\u041e\u0433\u043e, 314 \u041c\u0411, \u043d\u0435\u0443\u0436\u0435\u043b\u0438 docker build \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0430 Go \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 Java?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u0442\u0430\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/223\/05b\/407\/22305b40724bf0dc8435bcdbcd82994c.png\" width=\"1400\" height=\"340\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/223\/05b\/407\/22305b40724bf0dc8435bcdbcd82994c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 300+\u041c\u0411 \u0435\u0449\u0435 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e (WORKDIR). \u042d\u0442\u043e \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0436\u0435\u0441\u0442\u044c!<\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code>$ docker run --it --rm hello:v1  hello world!<\/code><\/pre>\n<p>\u041d\u0443 \u0442\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<h2>\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0433\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u043e\u0442 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043c\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043d\u0430\u043c\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0431\u044b\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<pre><code>$ docker images | grep golang  golang alpine d026981a7165 2 days ago 313MB<\/code><\/pre>\n<p>\u041e\u0434\u0438\u043d \u043c\u043e\u0439 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u0441\u043a\u0430\u0437\u0430\u043b \u043c\u043d\u0435, \u0447\u0442\u043e \u044f \u043c\u043e\u0433\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0431\u0435\u0437 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430, \u043d\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u0447\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u0440\u0438\u043b\u043e\u0436\u0438\u0432 \u043a \u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u0438\u043b\u0438\u044f, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <code>Dockerfile<\/code>:<\/p>\n<pre><code>FROM alpine  WORKDIR \/build  COPY hello .  CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c:<\/p>\n<pre><code>$ docker build -t hello:v2 . ... => ERROR [3\/3] COPY hello .                         0.0s ------  > [3\/3] COPY hello . : ------ failed to compute cache key: \"\/hello\" not found: not found<\/code><\/pre>\n<p>\u0422\u0430\u043a, <code>hello<\/code> \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u2014 \u0437\u043d\u0430\u0447\u0438\u0442, \u044f \u0437\u0430\u0431\u044b\u043b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c hello.go. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043d\u043e\u0432\u0430~<\/p>\n<pre><code>$ go build -o hello hello.go<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>docker build -t hello:v2 ..<\/code> \u0422\u0443\u0442 \u0443\u0436\u0435 \u0432\u0441\u0435 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0439 \u0432\u0434\u043e\u0445 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c:<\/p>\n<pre><code>$ docker run -it --rm hello:v2  standard_init_linux.go:228: exec user process caused: exec format error<\/code><\/pre>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430! \u0427\u0442\u043e \u0436, \u0444\u043e\u0440\u043c\u0430\u0442 \u043d\u0435 \u0442\u043e\u0442 \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043c\u0430\u0448\u0438\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435 \u043d\u0430 linux. \u0415\u0449\u0435 \u0440\u0430\u0437\u043e\u043a~<\/p>\n<pre><code>$ GOOS=linux go build -o hello hello.go<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c docker build. \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c:<\/p>\n<pre><code>$ docker run --it --rm hello:v2  hello world!<\/code><\/pre>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440:<\/p>\n<pre><code>$ docker run --it --rm hello:v2 ls -l \/build  total 1252  -rwxr-xr-x 1 root root 1281587 Mar 6 16:18 hello<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0442\u043e\u043b\u044c\u043a\u043e <code>hello<\/code>. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043e \u043b\u044e\u0434\u044f\u0445, \u043d\u0430\u0441\u043c\u0435\u0445\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430\u0434 \u043c\u043e\u0438\u043c \u043a\u043e\u0434\u043e\u043c ~<\/p>\n<pre><code>$ docker images | grep hello  hello v2 0dd53f016c93 53 seconds ago 6.61MB  hello v1 ac0e37173b85 25 minutes ago 314MB<\/code><\/pre>\n<p>\u0412\u0430\u0443, 6.61\u041c\u0411, \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e!<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/18d\/0df\/009\/18d0df009e35b217e60ecd27059fb002.png\" width=\"576\" height=\"206\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/18d\/0df\/009\/18d0df009e35b217e60ecd27059fb002.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e 5.3\u041c\u0411 \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 (WORKDIR), \u044f \u0443\u0436\u0435 \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432!<\/p>\n<h2>\u0422\u0440\u0435\u0442\u044c\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043c\u043e\u0435 \u043d\u0435\u0432\u0438\u043d\u043d\u043e\u0435 \u0445\u0432\u0430\u0441\u0442\u043e\u0432\u0441\u0442\u0432\u043e \u043a\u043e\u0435-\u043a\u0442\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043e\u043f\u0443\u0441\u0442\u0438\u043b \u043c\u0435\u043d\u044f \u043d\u0430 \u0437\u0435\u043c\u043b\u044e, \u0441\u043a\u0430\u0437\u0430\u0432, \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432. \u0422\u0430\u043a \u0447\u0442\u043e \u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u0441\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c? \u041f\u043e\u0440\u0430\u0437\u043c\u044b\u0441\u043b\u0438\u0432 \u043d\u0430\u0434 \u044d\u0442\u0438\u043c, \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 docker \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 Go, \u0447\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043d\u0430\u0441 \u0442\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0430:<\/p>\n<ol>\n<li>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 Go \u043d\u0430\u0442\u0438\u0432\u043d\u043e (\u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0443\u044e cgo \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e).<\/p>\n<\/li>\n<\/ol>\n<p>2. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 docker \u0441 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<p>3. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c shell-\u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u043b\u0438 makefile, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p>\u041c\u043d\u043e\u0433\u043e\u044d\u0442\u0430\u043f\u043d\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 Dockerfile \u2014 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0443\u0442\u0435\u0447\u0435\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0438 \u043e\u0431\u0440\u0430\u0437 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 Dockerfile, \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043c\u0435\u043d\u044c\u0448\u0435:<\/p>\n<pre><code>FROM golang:alpine AS builder  WORKDIR \/build  ADD go.mod .  COPY . .  RUN go build -o hello hello.go  FROM alpine  WORKDIR \/build  COPY --from=builder \/build\/hello \/build\/hello  CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 <code>FROM<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0431\u043e\u0440\u043a\u0438 builder-\u043e\u0431\u0440\u0430\u0437\u0430 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <code>hello<\/code>, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 <code>From<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <code>hello<\/code> \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 <code>alpine<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0431\u044b\u043b\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435. \u041f\u0440\u0438\u0447\u0438\u043d\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>scratch<\/code> \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>scratch<\/code> \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0432 \u0441\u0435\u0431\u044f \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043d\u0430\u0441 \u0434\u0430\u0436\u0435 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0430 <code>alpine<\/code> \u0432\u0435\u0441\u0438\u0442 \u0432\u0441\u0435\u0433\u043e 5\u041c\u0411, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441. \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>scratch<\/code> \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code>$ docker run --it --rm hello:v3  hello world!<\/code><\/pre>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c! \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440:<\/p>\n<pre><code>$ docker images | grep hello  hello v3 f51e1116be11 8 hours ago 6.61MB  hello v2 0dd53f016c93 8 hours ago 6.61MB  hello v1 ac0e37173b85 8 hours ago 314MB<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435. \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u0431\u0440\u0430\u0437\u0430:<\/p>\n<pre><code>$ docker run -it --rm hello:v3 ls -l \/build  total 1252  -rwxr-xr-x 1 root root 1281547 Mar 6 16:32 hello<\/code><\/pre>\n<p>\u041e\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b <code>hello<\/code>. \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e!<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/395\/9f0\/178\/3959f017825a084b7ce83570b55242c5.png\" width=\"790\" height=\"198\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/395\/9f0\/178\/3959f017825a084b7ce83570b55242c5.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043d\u043e \u043c\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>Dockerfile<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u044d\u0442\u0443 \u043c\u0443\u0442\u044c \u0441 <code>shell<\/code> \u0438 <code>makefile<\/code>.<\/p>\n<h2>\u0414\u043e\u0432\u043e\u0434\u0438\u043c \u0434\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0430<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0438 \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0438 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u0445\u0432\u0430\u043b\u044f\u0442 \u043c\u0435\u043d\u044f! \u041e\u0434\u043d\u0430\u043a\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u0438\u0448\u0443 \u0442\u0430\u043a\u043e\u0439 <code>Dockerfile<\/code>, \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u044d\u0442\u043e \u043d\u0430\u043f\u0440\u044f\u0433\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u0432\u0430\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c~<\/p>\n<pre><code># \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e  $ go install github.com\/zeromicro\/go-zero\/tools\/goctl@latest  # \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b Docker \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b  $ goctl docker -go hello.go<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e! \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>Dockerfile<\/code>.<\/p>\n<pre><code>FROM golang:alpine AS builder  LABEL stage=gobuilder  ENV CGO_ENABLED 0  ENV GOOS linux  RUN apk update --no-cache &amp;&amp; apk add --no-cache tzdata  WORKDIR \/build  ADD go.mod .  ADD go.sum .  RUN go mod download  COPY . .  RUN go build -ldflags=\"-s -w\" -o \/app\/hello . \/hello.go  FROM alpine  RUN apk update --no-cache &amp;&amp; apk add --no-cache ca-certificates  COPY --from=builder \/usr\/share\/zoneinfo\/America\/New_York \/usr\/share\/zoneinfo\/America\/New_York  ENV TZ America\/New_York  WORKDIR \/app  COPY --from=builder \/app\/hello \/app\/hello  CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043c\u0435\u0448\u0430\u043b\u043e \u0431\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><code>cgo<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 <code>-ldflags=\"-s -w\"<\/code> \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e ca-certificates, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TLS \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><code>tzdata<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 builder-\u043e\u0431\u0440\u0430\u0437 \u0431\u0438\u043b\u0434\u0435\u0440\u0430, \u0430 \u0432 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043d\u044b\u0439 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 New York.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e <code>Dockerfile<\/code>.<\/p>\n<pre><code>$ docker images | grep hello  hello v4 94ba3ece3071 4 hours ago 6.66MB  hello v3 f51e1116be11 8 hours ago 6.61MB  hello v2 0dd53f016c93 8 hours ago 6.61MB  hello v1 ac0e37173b85 9 hours ago 314MB<\/code><\/pre>\n<p>\u041e\u043d \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 ca-certificates \u0438 <code>tzdata<\/code>. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/746\/773\/83e\/74677383e65d55c5e4a9bdc97ee920eb.png\" width=\"1400\" height=\"261\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/746\/773\/83e\/74677383e65d55c5e4a9bdc97ee920eb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u0435:<\/p>\n<pre><code>$ docker run -it --rm hello:v4 ls -l \/app  total 832  -rwxr-xr-x 1 root root 851968 Mar 7 08:36 hello<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <code>hello<\/code>, \u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u0431\u044b\u043b \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d \u0441 1281\u041a\u0411 \u0434\u043e 851\u041a\u0411. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 shell-\u0444\u0430\u0439\u043b:<\/p>\n<pre><code>$ docker run --it --rm hello:v4  hello world!<\/code><\/pre>\n<p>\u0418 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 scratch \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 Dockerfile, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0437 \u0431\u044b\u043b \u043c\u0435\u043d\u044c\u0448\u0435, \u043d\u043e \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0439\u0442\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 <code>sh<\/code>.<\/p>\n<pre><code>$ goctl docker -base scratch -go hello.go<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0430\u043b \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435:<\/p>\n<pre><code>$ docker images | grep hello  hello v5 d084eed88d88 4 seconds ago 1.07MB  hello v4 94ba3ece3071 15 hours ago 6.66MB  hello v3 f51e1116be11 4 days ago 6.61MB  hello v2 0dd53f016c93 4 days ago 6.61MB  hello v1 ac0e37173b85 4 days ago 314MB<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438, \u0447\u0442\u043e \u0432 \u0437\u0435\u0440\u043a\u0430\u043b\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5af\/e5d\/d3c\/5afe5dd3c12878bef43911fea08a06ab.png\" width=\"1378\" height=\"232\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5af\/e5d\/d3c\/5afe5dd3c12878bef43911fea08a06ab.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 docker \u043a\u0440\u043e\u0441\u0441-\u0431\u0438\u043b\u0434\u0438\u043d\u0433 \u043e\u0431\u0440\u0430\u0437\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0447\u0438\u043f\u044b Apple Silicon, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>--platform linux\/amd64<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u0434\u043e\u043a\u0435\u0440\u043e\u0432 \u043f\u043e\u0434 linux\/amd64.<\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>upx<\/code> \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 <code>upx<\/code> \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>upx \/app\/hello<\/code> \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<pre><code>$ docker images | grep hello  hello\u00a0 v7\u00a0 491d2cf669c7 \u00a0 16 minutes ago \u00a0 548kB\u00a0 # amd64 after upx  hello\u00a0 v6\u00a0 0a80622b3310 \u00a0 7 days ago \u00a0 \u00a0 \u00a0 972kB\u00a0 # amd64  hello\u00a0 v5\u00a0 d084eed88d88 \u00a0 13 days ago\u00a0 \u00a0 \u00a0 1.07MB # arm64<\/code><\/pre>\n<p>\u041b\u0430\u0434\u043d\u043e, \u043b\u0430\u0434\u043d\u043e, \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u0432\u0430\u0442\u0438\u0442 <code>Dockerfile<\/code>, \u043f\u043e\u0440\u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043d\u0430\u0432\u044b\u043a\u0438~<\/p>\n<p>\u0421\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/github.com\/zeromicro\/go-zero\"><u>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 Github<\/u><\/a>.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a \u00ab\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b\u00bb. \u041d\u0430 \u0437\u0430\u043d\u044f\u0442\u0438\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f, \u043a\u0430\u043a: \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041f\u043e\u0431\u0435\u0441\u0435\u0434\u0443\u0435\u043c \u043f\u0440\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0443\u0441\u043f\u0435\u0442\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0438 \u043f\u0440\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0442\u044d\u0433\u0438 \u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 JSON, XML \u0438 \u0421\u0423\u0411\u0414. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u044f \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0430 \u0437\u0430\u043d\u044f\u0442\u0438\u0435 <a href=\"https:\/\/otus.pw\/wJPD\/\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/660301\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/660301\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0432\u0435\u0440\u0445\u0443\u0440\u043e\u0447\u043d\u044b\u0445 \u0447\u0430\u0441\u043e\u0432 \u043a\u0440\u043e\u043f\u043e\u0442\u043b\u0438\u0432\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0435 Hello world \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Go. \u0418 \u0445\u043e\u0442\u044f \u043e\u043d\u043e \u0432\u0441\u0435\u0433\u043e-\u043d\u0430\u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u043e \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u043b\u043e \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043c\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0438\u043a \u0431\u044b\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d, \u0447\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u043c\u0435\u043d\u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0435 \u0434\u0435\u0442\u0438\u0449\u0435, \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0432\u0435\u0441\u044c \u0441\u0432\u043e\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u044b\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439.<\/p>\n<pre><code>. \u251c\u2500\u2500 go.mod \u2514\u2500\u2500 hello.go<\/code><\/pre>\n<p>\u041a\u043e\u0434 <code>hello.go<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>package mainfunc main() {     println(\"hello world!\") }<\/code><\/pre>\n<p>\u0418 \u0435\u0449\u0435 \u043c\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0438\u043a \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c docker, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0435\u0435.<\/p>\n<h2>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043f\u0440\u043e\u0441\u0438\u0432 \u0441\u0432\u043e\u0438\u0445 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u043e\u0432\u0435\u0442\u044b, \u044f \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 docker, \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0432, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <code>Dockerfile<\/code>:<\/p>\n<pre><code>FROM golang:alpine WORKDIR \/build COPY hello.go . RUN go build -o hello hello.go CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u0418 \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437:<\/p>\n<pre><code>$ docker build -t hello:v1 .<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<pre><code>$ docker run -it --rm hello:v1 ls -l \/build  total 1260  -rwxr-xr-x 1 root root 1281547 Mar 6 15:54 hello  -rw-r--r-- 1 root root 55 Mar 6 14:59 hello.go<\/code><\/pre>\n<p>\u0412\u0435\u0441\u044c \u043c\u043e\u0439 \u043a\u043e\u0434 \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d \u0432 \u043e\u0431\u0440\u0430\u0437. \u041d\u043e \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043b\u043e\u0445\u043e\u0439 \u043a\u043e\u0434, \u0432\u0435\u0434\u044c \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u043a\u0430, \u0442\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0434\u043e \u043c\u043d\u043e\u0439 \u043f\u043e\u0442\u0435\u0448\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0437\u0435\u0440\u043a\u0430\u043b\u0430. \u0413\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u0440\u0430\u0437, \u0442\u0435\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 pull.<\/p>\n<pre><code>$ docker docker images | grep hello  hello v1 2783ee221014 44 minutes ago 314MB<\/code><\/pre>\n<p>\u041e\u0433\u043e, 314 \u041c\u0411, \u043d\u0435\u0443\u0436\u0435\u043b\u0438 docker build \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0430 Go \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 Java?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u0442\u0430\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 300+\u041c\u0411 \u0435\u0449\u0435 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e (WORKDIR). \u042d\u0442\u043e \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0436\u0435\u0441\u0442\u044c!<\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code>$ docker run --it --rm hello:v1  hello world!<\/code><\/pre>\n<p>\u041d\u0443 \u0442\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435\u0442, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<h2>\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0433\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u043e\u0442 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043c\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043d\u0430\u043c\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0431\u044b\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<pre><code>$ docker images | grep golang  golang alpine d026981a7165 2 days ago 313MB<\/code><\/pre>\n<p>\u041e\u0434\u0438\u043d \u043c\u043e\u0439 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u0441\u043a\u0430\u0437\u0430\u043b \u043c\u043d\u0435, \u0447\u0442\u043e \u044f \u043c\u043e\u0433\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0431\u0435\u0437 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430, \u043d\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u0447\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u0440\u0438\u043b\u043e\u0436\u0438\u0432 \u043a \u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u0438\u043b\u0438\u044f, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <code>Dockerfile<\/code>:<\/p>\n<pre><code>FROM alpine  WORKDIR \/build  COPY hello .  CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c:<\/p>\n<pre><code>$ docker build -t hello:v2 . ... => ERROR [3\/3] COPY hello .                         0.0s ------  > [3\/3] COPY hello . : ------ failed to compute cache key: \"\/hello\" not found: not found<\/code><\/pre>\n<p>\u0422\u0430\u043a, <code>hello<\/code> \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u2014 \u0437\u043d\u0430\u0447\u0438\u0442, \u044f \u0437\u0430\u0431\u044b\u043b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c hello.go. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043d\u043e\u0432\u0430~<\/p>\n<pre><code>$ go build -o hello hello.go<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>docker build -t hello:v2 ..<\/code> \u0422\u0443\u0442 \u0443\u0436\u0435 \u0432\u0441\u0435 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0439 \u0432\u0434\u043e\u0445 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c:<\/p>\n<pre><code>$ docker run -it --rm hello:v2  standard_init_linux.go:228: exec user process caused: exec format error<\/code><\/pre>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430! \u0427\u0442\u043e \u0436, \u0444\u043e\u0440\u043c\u0430\u0442 \u043d\u0435 \u0442\u043e\u0442 \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043c\u0430\u0448\u0438\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435 \u043d\u0430 linux. \u0415\u0449\u0435 \u0440\u0430\u0437\u043e\u043a~<\/p>\n<pre><code>$ GOOS=linux go build -o hello hello.go<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c docker build. \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c:<\/p>\n<pre><code>$ docker run --it --rm hello:v2  hello world!<\/code><\/pre>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440:<\/p>\n<pre><code>$ docker run --it --rm hello:v2 ls -l \/build  total 1252  -rwxr-xr-x 1 root root 1281587 Mar 6 16:18 hello<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0442\u043e\u043b\u044c\u043a\u043e <code>hello<\/code>. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043e \u043b\u044e\u0434\u044f\u0445, \u043d\u0430\u0441\u043c\u0435\u0445\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0430\u0434 \u043c\u043e\u0438\u043c \u043a\u043e\u0434\u043e\u043c ~<\/p>\n<pre><code>$ docker images | grep hello  hello v2 0dd53f016c93 53 seconds ago 6.61MB  hello v1 ac0e37173b85 25 minutes ago 314MB<\/code><\/pre>\n<p>\u0412\u0430\u0443, 6.61\u041c\u0411, \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e!<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e 5.3\u041c\u0411 \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 (WORKDIR), \u044f \u0443\u0436\u0435 \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432!<\/p>\n<h2>\u0422\u0440\u0435\u0442\u044c\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043c\u043e\u0435 \u043d\u0435\u0432\u0438\u043d\u043d\u043e\u0435 \u0445\u0432\u0430\u0441\u0442\u043e\u0432\u0441\u0442\u0432\u043e \u043a\u043e\u0435-\u043a\u0442\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043e\u043f\u0443\u0441\u0442\u0438\u043b \u043c\u0435\u043d\u044f \u043d\u0430 \u0437\u0435\u043c\u043b\u044e, \u0441\u043a\u0430\u0437\u0430\u0432, \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432. \u0422\u0430\u043a \u0447\u0442\u043e \u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u0441\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c? \u041f\u043e\u0440\u0430\u0437\u043c\u044b\u0441\u043b\u0438\u0432 \u043d\u0430\u0434 \u044d\u0442\u0438\u043c, \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 docker \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 Go, \u0447\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043d\u0430\u0441 \u0442\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0430:<\/p>\n<ol>\n<li>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 Go \u043d\u0430\u0442\u0438\u0432\u043d\u043e (\u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0443\u044e cgo \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e).<\/p>\n<\/li>\n<\/ol>\n<p>2. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437 docker \u0441 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<p>3. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c shell-\u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u043b\u0438 makefile, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p>\u041c\u043d\u043e\u0433\u043e\u044d\u0442\u0430\u043f\u043d\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 Dockerfile \u2014 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0443\u0442\u0435\u0447\u0435\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0438 \u043e\u0431\u0440\u0430\u0437 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 Dockerfile, \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043c\u0435\u043d\u044c\u0448\u0435:<\/p>\n<pre><code>FROM golang:alpine AS builder  WORKDIR \/build  ADD go.mod .  COPY . .  RUN go build -o hello hello.go  FROM alpine  WORKDIR \/build  COPY --from=builder \/build\/hello \/build\/hello  CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 <code>FROM<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0431\u043e\u0440\u043a\u0438 builder-\u043e\u0431\u0440\u0430\u0437\u0430 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <code>hello<\/code>, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 <code>From<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <code>hello<\/code> \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 <code>alpine<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u0431\u044b\u043b\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435. \u041f\u0440\u0438\u0447\u0438\u043d\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>scratch<\/code> \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>scratch<\/code> \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0432 \u0441\u0435\u0431\u044f \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043d\u0430\u0441 \u0434\u0430\u0436\u0435 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0430 <code>alpine<\/code> \u0432\u0435\u0441\u0438\u0442 \u0432\u0441\u0435\u0433\u043e 5\u041c\u0411, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441. \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>scratch<\/code> \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code>$ docker run --it --rm hello:v3  hello world!<\/code><\/pre>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c! \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440:<\/p>\n<pre><code>$ docker images | grep hello  hello v3 f51e1116be11 8 hours ago 6.61MB  hello v2 0dd53f016c93 8 hours ago 6.61MB  hello v1 ac0e37173b85 8 hours ago 314MB<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435. \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043e\u0431\u0440\u0430\u0437\u0430:<\/p>\n<pre><code>$ docker run -it --rm hello:v3 ls -l \/build  total 1252  -rwxr-xr-x 1 root root 1281547 Mar 6 16:32 hello<\/code><\/pre>\n<p>\u041e\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b <code>hello<\/code>. \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e!<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437, \u043d\u043e \u043c\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>Dockerfile<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u044d\u0442\u0443 \u043c\u0443\u0442\u044c \u0441 <code>shell<\/code> \u0438 <code>makefile<\/code>.<\/p>\n<h2>\u0414\u043e\u0432\u043e\u0434\u0438\u043c \u0434\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0430<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0438 \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0438 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u0445\u0432\u0430\u043b\u044f\u0442 \u043c\u0435\u043d\u044f! \u041e\u0434\u043d\u0430\u043a\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u0438\u0448\u0443 \u0442\u0430\u043a\u043e\u0439 <code>Dockerfile<\/code>, \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u044d\u0442\u043e \u043d\u0430\u043f\u0440\u044f\u0433\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u0432\u0430\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c~<\/p>\n<pre><code># \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e  $ go install github.com\/zeromicro\/go-zero\/tools\/goctl@latest  # \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b Docker \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b  $ goctl docker -go hello.go<\/code><\/pre>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e! \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>Dockerfile<\/code>.<\/p>\n<pre><code>FROM golang:alpine AS builder  LABEL stage=gobuilder  ENV CGO_ENABLED 0  ENV GOOS linux  RUN apk update --no-cache &amp;&amp; apk add --no-cache tzdata  WORKDIR \/build  ADD go.mod .  ADD go.sum .  RUN go mod download  COPY . .  RUN go build -ldflags=\"-s -w\" -o \/app\/hello . \/hello.go  FROM alpine  RUN apk update --no-cache &amp;&amp; apk add --no-cache ca-certificates  COPY --from=builder \/usr\/share\/zoneinfo\/America\/New_York \/usr\/share\/zoneinfo\/America\/New_York  ENV TZ America\/New_York  WORKDIR \/app  COPY --from=builder \/app\/hello \/app\/hello  CMD [\". \/hello\"]<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u043c\u0435\u0448\u0430\u043b\u043e \u0431\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><code>cgo<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 <code>-ldflags=\"-s -w\"<\/code> \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e ca-certificates, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TLS \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><code>tzdata<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 builder-\u043e\u0431\u0440\u0430\u0437 \u0431\u0438\u043b\u0434\u0435\u0440\u0430, \u0430 \u0432 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043d\u044b\u0439 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 New York.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e <code>Dockerfile<\/code>.<\/p>\n<pre><code>$ docker images | grep hello  hello v4 94ba3ece3071 4 hours ago 6.66MB  hello v3 f51e1116be11 8 hours ago 6.61MB  hello v2 0dd53f016c93 8 hours ago 6.61MB  hello v1 ac0e37173b85 9 hours ago 314MB<\/code><\/pre>\n<p>\u041e\u043d \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 ca-certificates \u0438 <code>tzdata<\/code>. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0431\u0440\u0430\u0437\u0435:<\/p>\n<pre><code>$ docker run -it --rm hello:v4 ls -l \/app  total 832  -rwxr-xr-x 1 root root 851968 Mar 7 08:36 hello<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <code>hello<\/code>, \u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u0431\u044b\u043b \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d \u0441 1281\u041a\u0411 \u0434\u043e 851\u041a\u0411. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 shell-\u0444\u0430\u0439\u043b:<\/p>\n<pre><code>$ docker run --it --rm hello:v4  hello world!<\/code><\/pre>\n<p>\u0418 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 scratch \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 Dockerfile, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0437 \u0431\u044b\u043b \u043c\u0435\u043d\u044c\u0448\u0435, \u043d\u043e \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0439\u0442\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 <code>sh<\/code>.<\/p>\n<pre><code>$ goctl docker -base scratch -go hello.go<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0430\u043b \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435:<\/p>\n<pre><code>$ docker images | grep hello  hello v5 d084eed88d88 4 seconds ago 1.07MB  hello v4 94ba3ece3071 15 hours ago 6.66MB  hello v3 f51e1116be11 4 days ago 6.61MB  hello v2 0dd53f016c93 4 days ago 6.61MB  hello v1 ac0e37173b85 4 days ago 314MB<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438, \u0447\u0442\u043e \u0432 \u0437\u0435\u0440\u043a\u0430\u043b\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 docker \u043a\u0440\u043e\u0441\u0441-\u0431\u0438\u043b\u0434\u0438\u043d\u0433 \u043e\u0431\u0440\u0430\u0437\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0447\u0438\u043f\u044b Apple Silicon, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>--platform linux\/amd64<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u0434\u043e\u043a\u0435\u0440\u043e\u0432 \u043f\u043e\u0434 linux\/amd64.<\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>upx<\/code> \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 <code>upx<\/code> \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>upx \/app\/hello<\/code> \u043f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<pre><code>$ docker images | grep hello  hello\u00a0 v7\u00a0 491d2cf669c7 \u00a0 16 minutes ago \u00a0 548kB\u00a0 # amd64 after upx  hello\u00a0 v6\u00a0 0a80622b3310 \u00a0 7 days ago \u00a0 \u00a0 \u00a0 972kB\u00a0 # amd64  hello\u00a0 v5\u00a0 d084eed88d88 \u00a0 13 days ago\u00a0 \u00a0 \u00a0 1.07MB # arm64<\/code><\/pre>\n<p>\u041b\u0430\u0434\u043d\u043e, \u043b\u0430\u0434\u043d\u043e, \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u0432\u0430\u0442\u0438\u0442 <code>Dockerfile<\/code>, \u043f\u043e\u0440\u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043d\u0430\u0432\u044b\u043a\u0438~<\/p>\n<p>\u0421\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/github.com\/zeromicro\/go-zero\"><u>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 Github<\/u><\/a>.<\/p>\n<hr\/>\n<p>\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a \u00ab\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b\u00bb. \u041d\u0430 \u0437\u0430\u043d\u044f\u0442\u0438\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f, \u043a\u0430\u043a: \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041f\u043e\u0431\u0435\u0441\u0435\u0434\u0443\u0435\u043c \u043f\u0440\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0443\u0441\u043f\u0435\u0442\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0438 \u043f\u0440\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0442\u044d\u0433\u0438 \u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 JSON, XML \u0438 \u0421\u0423\u0411\u0414. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u044f \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0430 \u0437\u0430\u043d\u044f\u0442\u0438\u0435 <a href=\"https:\/\/otus.pw\/wJPD\/\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/660301\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/660301\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331792","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331792"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331792\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}