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

Do away with HTTP server and instead used a Go based File server for hosting binaries #346

Open
wants to merge 4 commits into
base: master
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
22 changes: 14 additions & 8 deletions Dockerfile.serve
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
FROM openshift/origin-release:golang-1.20 AS builder
FROM openshift/origin-release:golang-1.21 AS builder

WORKDIR /tmp/kam
COPY . .
RUN make all_platforms
RUN make checksum
RUN make all_platforms && \
make checksum && \
CGO_ENABLED=0 go build -o /tmp/kamserve tools/kam-serve/main.go && \
mkdir -p /tmp/workdir/kam-root/kam && \
cp config/index.html /tmp/workdir/kam-root/index.html && \
mv /tmp/kam/dist/* /tmp/workdir/kam-root/kam/


FROM registry.redhat.io/rhel8/httpd-24
FROM scratch

# Add application sources
RUN mkdir -p /var/www/html/kam
COPY --from=builder /tmp/kam/dist/kam_windows_amd64.exe /tmp/kam/dist/kam_windows_arm64.exe /tmp/kam/dist/kam_linux_amd64 /tmp/kam/dist/kam_linux_arm64 /tmp/kam/dist/kam_linux_ppc64le /tmp/kam/dist/kam_linux_s390x /tmp/kam/dist/kam_darwin_amd64 /tmp/kam/dist/kam_darwin_arm64 /tmp/kam/dist/kam_checksums.txt /var/www/html/kam/
COPY config/index.html /var/www/html/index.html
COPY --from=builder /tmp/workdir/ /tmp/
COPY --from=builder /tmp/kamserve /

EXPOSE 9000

# The run script uses standard ways to run the application
CMD run-httpd
ENTRYPOINT ["./kamserve"]
18 changes: 18 additions & 0 deletions tools/kam-serve/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
"net/http"
)

func main() {
fs := http.FileServer(http.Dir("/tmp/kam-root"))

fmt.Println("Listening on port 9000 to serve directory contents /tmp/kam-root")

err := http.ListenAndServe(":9000", fs)

if err != nil {
panic(err)
}
}
Loading