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

added dockerfile #55

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

added dockerfile #55

wants to merge 4 commits into from

Conversation

leisefuxX
Copy link

  • added wanky dockerfile in contrib/docker
  • go code is untouched
  • added docker in readme

Julian Hamann added 4 commits February 18, 2024 11:52
added and testet dockerfile
added dockerfile and updated readme
@oxzi oxzi mentioned this pull request Feb 22, 2024
Copy link
Owner

@oxzi oxzi left a 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
Copy link
Owner

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
Copy link
Owner

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 . .
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you explicitly COPYed go.{mod,sum} before, and now COPY everything?

## import image
FROM alpine:latest
## install certificates
RUN apk add ca-certificates
Copy link
Owner

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 .
Copy link
Owner

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
Copy link
Owner

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"]
Copy link
Owner

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.

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.

2 participants