Skip to content

Commit

Permalink
test commit
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Alba <[email protected]>
  • Loading branch information
samalba committed Oct 28, 2024
1 parent a86efce commit 0af787b
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/dagger.yml
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
14 changes: 14 additions & 0 deletions Dockerfile
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"]
35 changes: 35 additions & 0 deletions app.go
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))
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/fly-apps/go-example

go 1.22
Empty file added go.sum
Empty file.
15 changes: 15 additions & 0 deletions templates/index.html.tmpl
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>

0 comments on commit 0af787b

Please sign in to comment.