-
Notifications
You must be signed in to change notification settings - Fork 3
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
added dockerfile #55
base: main
Are you sure you want to change the base?
added dockerfile #55
Conversation
leisefuxX
commented
Feb 18, 2024
- added wanky dockerfile in contrib/docker
- go code is untouched
- added docker in readme
added and testet dockerfile
added dockerfile and updated readme
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.
Thanks a lot for your PR!
Please excuse the amount of comments I have added.
|
||
or | ||
|
||
use provided image from dockerhub |
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.
Thanks for providing a Docker image! However, the tagged version 0.6.0 is kinda outdated and lots have changed in the meantime, which I haven't completed into its own release, yet.
Maybe add a your username next to it, so that people are able to ping you for updates? Otherwise, this image should be built automatically through the CI.
FROM golang:alpine AS build_base | ||
|
||
## add git | ||
RUN apk add --no-cache git |
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.
What do you need git
for?
RUN go mod download | ||
|
||
## copy all files into build stage | ||
COPY . . |
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.
Why did you explicitly COPY
ed go.{mod,sum}
before, and now COPY
everything?
## import image | ||
FROM alpine:latest | ||
## install certificates | ||
RUN apk add 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.
What do you need the ca-certificates
for?
## copy all files into build stage | ||
COPY . . | ||
## BUILD BUILD BUILD! | ||
RUN go build -o ./out/gosh . |
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.
Maybe do a static build through CGO_ENABLED=0
?
COPY --from=build_base /go/out/gosh /app/gosh | ||
|
||
## copy files from build stage to run stage | ||
COPY --from=build_base /go/* /app |
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.
Why? The single gosh
binary should be enough.
## expose port | ||
EXPOSE 8080 | ||
## run app | ||
CMD ["/app/gosh", "-config", "/app/gosh.yml"] |
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.
In this case, gosh would be run as the root user, but no other users where added. Thus, gosh cannot drop privileges to another user and would be executed as root.