-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Loki]: Cleanup dockerfile #1949
[Loki]: Cleanup dockerfile #1949
Conversation
setep is probably not needed anymore due to 3100 being the default port. Also, I'm not sure the amd64 binary works on other arch binaries.
Codecov Report
@@ Coverage Diff @@
## master #1949 +/- ##
==========================================
- Coverage 64.75% 64.67% -0.09%
==========================================
Files 125 125
Lines 9539 9539
==========================================
- Hits 6177 6169 -8
- Misses 2929 2942 +13
+ Partials 433 428 -5
|
cmd/loki/loki-local-config.yaml
Outdated
@@ -27,10 +27,10 @@ schema_config: | |||
|
|||
storage_config: | |||
boltdb: | |||
directory: /loki/index | |||
directory: /data/loki/index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slim-bean you mentioned something about this ? I think you're good with that change right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this used to be /tmp a long time ago and got changed to /loki
/loki is annoying because many operating systems don't easily let you create this directory
I don't know if /data makes this any easier? my mac is dead at the moment, can you create /data (or does it exist) on mac?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No so it's the same :)
sudo mkdir /data
Password:
mkdir: /data: Read-only file system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be favor of moving this back to /tmp
if we were going to change it all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cyriltovena Did you run that inside the OSX docker hypervisor? By default that directory isn't shared with the host (see https://docs.docker.com/docker-for-mac/#file-sharing)
So do you want the consistency with the helm image or /tmp
in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are talking about running locally on mac, not in docker at all. This is useful for us for testing/debugging etc, just run the processes and use the loki-local-config.yaml.
This broke however when it was changed to /loki
some time ago because you can't make this directory on a mac (nor /data
)
#1833 changed this apparently, however /loki
is also kind of a poor choice, it's both unusable on mac and not linux FHS compliant.
Given the sort of dual use of this file as both the config file for a container and also running outside of containers I'm not sure the best path forward here to be honest
I'm inclined to say just leave it as is for now and we should tackle this in a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've removed the config file change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, this is great research/work -- thanks. I had a few nitpicks, but overall it seems a nice addition. I'll approve and if others feel similarly, please make my proposed caching-related dockerfile changes.
@@ -7,20 +7,21 @@ WORKDIR /src/loki | |||
RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false loki | |||
|
|||
FROM alpine:3.9 | |||
RUN apk add --update --no-cache ca-certificates libcap \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a tradeoff here of caching vs layer reduction and I'm inclined to think that caching is a bit more preferrable although I'm biased by building this regularly. That being said, I don't think it's a huge deal either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry deleted my last message, didn't read closely enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd like to leave this as is, same as the changes below for 2 reasons:
- We spent a stupid amount of time trying to test this worked after adding this change and I don't have time to redo this.
- I prefer the separate run steps below I think it's easier to read and understand what the steps are doing/for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate on what you spent a lot of time testing? Adding a new package should be as simple as adding an apk add --no-cache <pkgname>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the cap stuff was new and we tried several combinations of where to install libcap
as well as removing it and where to remove it to keep the resulting image size as small as possible as well as make sure it still works.
@@ -13,9 +13,21 @@ WORKDIR /src/loki | |||
RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki | |||
|
|||
FROM alpine:3.9 | |||
RUN apk add --update --no-cache ca-certificates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should remain earlier in the file for caching benefits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved back to the top
cmd/loki/loki-local-config.yaml
Outdated
@@ -27,10 +27,10 @@ schema_config: | |||
|
|||
storage_config: | |||
boltdb: | |||
directory: /loki/index | |||
directory: /data/loki/index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, thanks for the consistency!
cmd/loki/Dockerfile
Outdated
RUN addgroup -g 10001 -S loki && \ | ||
adduser -u 10001 -S loki -G loki && \ | ||
mkdir -p /data && \ | ||
chown -R loki:loki /etc/loki /data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, would prefer to leave this as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, separated out into two steps again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I dealt with or responded to all the comments.
@owen-d You mentioned you preferred caching over smaller images so I removed the apk del --no-cache libcap
that would've been later in the file otherwise. This removes an extra download of the apk repositories. It's not really needed as it won't reduce the size of the image (since it's in a separate RUN
step).
@@ -7,20 +7,21 @@ WORKDIR /src/loki | |||
RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false loki | |||
|
|||
FROM alpine:3.9 | |||
RUN apk add --update --no-cache ca-certificates libcap \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate on what you spent a lot of time testing? Adding a new package should be as simple as adding an apk add --no-cache <pkgname>
.
cmd/loki/Dockerfile
Outdated
RUN addgroup -g 10001 -S loki && \ | ||
adduser -u 10001 -S loki -G loki && \ | ||
mkdir -p /data && \ | ||
chown -R loki:loki /etc/loki /data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, separated out into two steps again
@@ -13,9 +13,21 @@ WORKDIR /src/loki | |||
RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki | |||
|
|||
FROM alpine:3.9 | |||
RUN apk add --update --no-cache ca-certificates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved back to the top
cmd/loki/loki-local-config.yaml
Outdated
@@ -27,10 +27,10 @@ schema_config: | |||
|
|||
storage_config: | |||
boltdb: | |||
directory: /loki/index | |||
directory: /data/loki/index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cyriltovena Did you run that inside the OSX docker hypervisor? By default that directory isn't shared with the host (see https://docs.docker.com/docker-for-mac/#file-sharing)
So do you want the consistency with the helm image or /tmp
in this file?
What this PR does / why we need it:
Dockerfile.cross
to match the plainDockerfile
exceptsetep
as I'm not sure the amd64 binary will work on cross-compiled binariesWhich issue(s) this PR fixes:
Fixes #1928
Special notes for your reviewer:
The PRs that changed the user/group ID and data directory haven't made it into a release yet so this should be safe to change.
I couldn't test this as GolangCI shutdown yesterday.
Checklist