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

Tiny 404 webserver. #1

Open
wants to merge 1 commit 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
16 changes: 16 additions & 0 deletions web-404/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.22.2 as build

WORKDIR /go/src/app
COPY . .

RUN go mod download
RUN go vet -v
RUN go test -v

RUN CGO_ENABLED=0 go build -o /go/bin/app

FROM gcr.io/distroless/static-debian11

EXPOSE 80/tcp
COPY --from=build /go/bin/app /
CMD ["/app"]
3 changes: 3 additions & 0 deletions web-404/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/410Labs/dockerfiles/tree/master/web-404

go 1.22.2
26 changes: 26 additions & 0 deletions web-404/web-404.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"net/http"
"fmt"
)

var page = `
<html>
<head></head>
<body>
<h1>Chuck Pro</h1>
<p>Path not found.</p>
</body>
</html>
`

func handler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, page)
}

func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":80", nil)
}