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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,30 @@ server "example.org" {

Don't forget to `rcctl reload httpd` your configuration changes.

### Docker

Clone repo, alter gosh.yaml according to your needs and build container with contrib/docker/dockerfile

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.


``` docker-compose
version: "3.8"
services:
gosh:
image: gorja/gosh:0.6.0
restart: unless-stopped
ports:
- 8080:80
```

or if you prefer docker run command

``` docker run
docker run -p 8080:80 gorja/gosh:0.6.0
```


## Running gosh

Expand Down
38 changes: 38 additions & 0 deletions contrib/docker/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# build stage
## import image
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?


## cd into global 700 dir (image specific)
WORKDIR /go

## populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
## download the modules
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?

## 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?



# run stage
## 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 app from build stage to run stage
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.

Loading