siennathesane / cloudflare-sync

A nice to have, MIT-licensed tool for using Cloudflare as a dynamic DNS provider.
MIT License
268 stars 19 forks source link

improve docker build #8

Closed inductor closed 4 years ago

inductor commented 5 years ago

Addressed to this: https://github.com/mxplusb/cloudflare-sync/issues/7 and better docker building strategy using multi-stage build

inductor commented 5 years ago

@mxplusb I believe you at least need the minor version stability for the base image, unless you actually make tests or at least CI environment. What do you think?

inductor commented 5 years ago

Also I'm explaining this for you just in case because the following lines are especially for Dockerfile design wise purpose and you might miss what I did here.

# If this is in the cache, the go mod download part will be ignored
COPY go.mod go.sum ./
RUN GO111MODULE=on go mod download

# This will not be as-is since most cases you make changes in source code
COPY . .
RUN go build -o cloudflare-sync

These lines should be important because go.mod and go.sum is less frequently changed than the source code lines. That means by separating these works for better caching of Docker image layers.

siennathesane commented 4 years ago

@inductor thanks for your contribution, sorry for letting it languish, life got busy. I don't think I'm going to accept this change. The docker build as it exists right now is simple and works, so I'm going to leave it for now.

Please don't let this prevent you from contributing more, I'm just not interested in this specific change. Thank you, though!