Skip to content

feat: docker build - #119

Open
liuzheng wants to merge 1 commit into
abh:mainfrom
liuzheng:main
Open

feat: docker build#119
liuzheng wants to merge 1 commit into
abh:mainfrom
liuzheng:main

Conversation

@liuzheng

Copy link
Copy Markdown

Docker image build with multi-stage and save build time.
Some code in Dockerfile is useless, such as

Dockerfile:
-ADD applog/ applog/
-ADD countries/ countries/
-ADD geodns-logs/ geodns-logs/
-ADD health/ health/
-ADD monitor/ monitor/
-ADD querylog/ querylog/
-ADD server/ server/
-ADD targeting/ targeting/
-ADD typeutil/ typeutil/
-ADD zones/ zones/
-ADD service/ service/
-ADD service-logs/ service-logs/
-ADD *.go build ./

+COPY . /goapp

There is no need to add code one by one. Use .dockerignore then one COPY .

Dockerfile:
+FROM golang as prepare
+COPY go.mod go.sum /goapp/
+WORKDIR /goapp/
+RUN go mod download

-ADD vendor/ vendor/

.dockerignore:
+.git/
+.idea/
+vendor/
+dist/

This change because vendor/ not always same in any OS system. Use stage prepare to download packages can save time.

Build Docker image

make docker-build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant