MVP test suite

This commit is contained in:
Lance Vick 2023-11-14 16:30:48 -08:00
parent 2b2ec9f7f7
commit 1f44df6c32
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
5 changed files with 27 additions and 32 deletions

View File

@ -35,3 +35,9 @@ out/go.oci.tgz: \
out/bash.oci.tgz \
out/musl.oci.tgz
docker build -t ocirep/go --output type=oci,dest=$@ packages/go
test:
docker build -t ocirep/go_hello examples/go_hello
@printf "\nOcirep Test Suite\n"
@printf "go_hello -> "
@docker run -i ocirep/go_hello | grep Success

View File

@ -0,0 +1,14 @@
FROM ocirep/busybox as build
COPY --from=ocirep/go . /
COPY . .
RUN \
go build main.go \
&& mkdir -p $HOME/rootfs/etc \
&& echo "nogroup:*:100:nobody" > ~/rootfs/etc/group \
&& echo "nobody:*:100:100:::" > ~/rootfs/etc/passwd \
&& cp main $HOME/rootfs/
FROM scratch
COPY --from=build --chown=100:100 /home/user/rootfs /
USER 100:100
ENTRYPOINT ["/main"]

View File

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("Success")
}

View File

@ -1,17 +0,0 @@
ARG GO_IMAGE=ocirep:go
FROM ${GO_IMAGE} as build
COPY . .
RUN \
go build main.go \
&& mkdir -p rootfs/etc \
&& echo "nogroup:*:100:nobody" > ~/rootfs/etc/group \
&& echo "nobody:*:100:100:::" > ~/rootfs/etc/passwd \
&& cp main rootfs/
ARG CA_IMAGE=ocirep:ca-certificates
FROM scratch
COPY --from=${CA_IMAGE} /
COPY --from=build --chown=100:100 rootfs /
USER 100:100
EXPOSE 8080
ENTRYPOINT main

View File

@ -1,15 +0,0 @@
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", HelloServer)
http.ListenAndServe(":8080", nil)
}
func HelloServer(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
}