Skip to content

Commit 0af787b

Browse files
committed
test commit
Signed-off-by: Sam Alba <[email protected]>
1 parent a86efce commit 0af787b

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed

.github/workflows/dagger.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: dagger
2+
on:
3+
push:
4+
branches: [main]
5+
6+
jobs:
7+
test:
8+
name: test
9+
runs-on: depot-ubuntu-22.04,dagger=0.13.6
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Test
14+
uses: dagger/dagger-for-github@v6
15+
with:
16+
version: "0.13.6"
17+
verb: call
18+
module: github.com/kpenfound/dagger-modules/[email protected]
19+
args: test --source=.
20+
build:
21+
name: build
22+
runs-on: ubuntu-latest
23+
needs: test
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- name: Call Dagger Function
28+
uses: dagger/dagger-for-github@v6
29+
with:
30+
version: "latest"
31+
verb: call
32+
module: github.com/kpenfound/dagger-modules/[email protected]
33+
args: build-container --source=. --args=. publish --address=ttl.sh/my-app-$RANDOM:2h

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.23 AS builder
2+
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
8+
COPY *.go ./
9+
COPY ./templates ./templates
10+
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/app-bin
11+
12+
FROM alpine:3.20
13+
COPY --from=builder /app/app-bin /app/app-bin
14+
ENTRYPOINT ["/app/app-bin"]

app.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package main
2+
3+
import (
4+
"embed"
5+
"html/template"
6+
"log"
7+
"net/http"
8+
"os"
9+
"strings"
10+
)
11+
12+
//go:embed templates/*
13+
var resources embed.FS
14+
15+
var t = template.Must(template.ParseFS(resources, "templates/*"))
16+
17+
func main() {
18+
port := os.Getenv("PORT")
19+
if port == "" {
20+
port = "8080"
21+
22+
}
23+
24+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
25+
data := map[string]string{
26+
"text": os.Getenv("TEXT"),
27+
"env": strings.Join(os.Environ(), "\n"),
28+
}
29+
30+
t.ExecuteTemplate(w, "index.html.tmpl", data)
31+
})
32+
33+
log.Println("listening on", port)
34+
log.Fatal(http.ListenAndServe(":"+port, nil))
35+
}

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/fly-apps/go-example
2+
3+
go 1.22

go.sum

Whitespace-only changes.

templates/index.html.tmpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
</head>
5+
<body>
6+
<h1>Hello from Sam's page</h1>
7+
{{ if .text }}
8+
<pre>{{.text}}</pre>
9+
{{end}}
10+
<h2>Environ:</h2>
11+
<pre>
12+
{{.env}}
13+
</pre>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)