From 86a77515f1853f7d5befd06ee60df3b5c4fe4cd4 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Sun, 27 Nov 2022 23:39:35 +0100 Subject: [PATCH] Initial --- Dockerfile | 9 +++++++++ README.md | 11 +++++++++++ go.mod | 3 +++ test.go | 21 +++++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 go.mod create mode 100644 test.go diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..11e46fc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM golang:alpine as build +WORKDIR /root +COPY . . +RUN go build + +FROM alpine +COPY --from=build /root/test /root/test +EXPOSE 5000 +ENTRYPOINT ["/root/test"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..e72d7b7 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Firewall test container + +## Build + + $ docker build -t git.okoyono.de/f/firewall-test:latest . + $ docker push git.okoyono.de/f/firewall-test:latest + +## Run + + $ docker pull git.okoyono.de/f/firewall-test + $ docker run git.okoyono.de/f/firewall-test diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6cad3e9 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module test + +go 1.19 diff --git a/test.go b/test.go new file mode 100644 index 0000000..ffebaa5 --- /dev/null +++ b/test.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + "net/http" +) + +func main() { + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + resp, err := http.Get("https://aaron-fischer.net/ryg") + if err != nil { + fmt.Printf("err: %v", err) + } + + fmt.Printf("Resp: %v", resp.Status) + fmt.Fprintf(w, "Request from within the container to a website (Port 443): %v", resp.Status) + }) + + log.Fatal(http.ListenAndServe(":5000", nil)) +}