-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sam Alba <[email protected]>
- Loading branch information
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: dagger | ||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
name: test | ||
runs-on: depot-ubuntu-22.04,dagger=0.13.6 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Test | ||
uses: dagger/dagger-for-github@v6 | ||
with: | ||
version: "0.13.6" | ||
verb: call | ||
module: github.com/kpenfound/dagger-modules/[email protected] | ||
args: test --source=. | ||
build: | ||
name: build | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Call Dagger Function | ||
uses: dagger/dagger-for-github@v6 | ||
with: | ||
version: "latest" | ||
verb: call | ||
module: github.com/kpenfound/dagger-modules/[email protected] | ||
args: build-container --source=. --args=. publish --address=ttl.sh/my-app-$RANDOM:2h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM golang:1.23 AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY *.go ./ | ||
COPY ./templates ./templates | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/app-bin | ||
|
||
FROM alpine:3.20 | ||
COPY --from=builder /app/app-bin /app/app-bin | ||
ENTRYPOINT ["/app/app-bin"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"embed" | ||
"html/template" | ||
"log" | ||
"net/http" | ||
"os" | ||
"strings" | ||
) | ||
|
||
//go:embed templates/* | ||
var resources embed.FS | ||
|
||
var t = template.Must(template.ParseFS(resources, "templates/*")) | ||
|
||
func main() { | ||
port := os.Getenv("PORT") | ||
if port == "" { | ||
port = "8080" | ||
|
||
} | ||
|
||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
data := map[string]string{ | ||
"text": os.Getenv("TEXT"), | ||
"env": strings.Join(os.Environ(), "\n"), | ||
} | ||
|
||
t.ExecuteTemplate(w, "index.html.tmpl", data) | ||
}) | ||
|
||
log.Println("listening on", port) | ||
log.Fatal(http.ListenAndServe(":"+port, nil)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/fly-apps/go-example | ||
|
||
go 1.22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
</head> | ||
<body> | ||
<h1>Hello from Sam's page</h1> | ||
{{ if .text }} | ||
<pre>{{.text}}</pre> | ||
{{end}} | ||
<h2>Environ:</h2> | ||
<pre> | ||
{{.env}} | ||
</pre> | ||
</body> | ||
</html> |