Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docker build #119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: docker build #119

wants to merge 1 commit into from

Conversation

liuzheng
Copy link

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