diff --git a/Dockerfile.serve b/Dockerfile.serve index 524c3cb85..e7ba1fd5e 100644 --- a/Dockerfile.serve +++ b/Dockerfile.serve @@ -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"] diff --git a/tools/kam-serve/main.go b/tools/kam-serve/main.go new file mode 100644 index 000000000..67511c375 --- /dev/null +++ b/tools/kam-serve/main.go @@ -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) + } +}