-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ebd2314
Showing
8 changed files
with
142 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,29 @@ | ||
name: Build docker image | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./app | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
ghcr.io/spacelift-io/spacelift-operator-demo:latest | ||
ghcr.io/spacelift-io/spacelift-operator-demo:${{ github.sha }} |
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,11 @@ | ||
FROM golang:1.21.7 as builder | ||
WORKDIR /build | ||
COPY . . | ||
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o demo . | ||
|
||
FROM scratch | ||
COPY --from=builder /build/demo /bin/demo | ||
ENTRYPOINT ["/bin/demo"] | ||
|
||
|
||
|
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/spacelift-io/spacelift-operator-demo | ||
|
||
go 1.21.7 |
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,41 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"log" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
func readSecret() string { | ||
f, err := os.Open("/secrets/RANDOM_STRING") | ||
if err != nil { | ||
return "" | ||
} | ||
data, err := io.ReadAll(f) | ||
if err != nil { | ||
return "" | ||
} | ||
return string(data) | ||
} | ||
|
||
func main() { | ||
listenAddr := ":8888" | ||
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { | ||
log.Println(request.Method, request.URL.String()) | ||
if request.URL.Path != "/" { | ||
writer.WriteHeader(http.StatusNotFound) | ||
return | ||
} | ||
resp := fmt.Sprintf("RANDOM_STRING=%s", readSecret()) | ||
_, _ = writer.Write([]byte(resp)) | ||
}) | ||
log.Printf("Listening on %s\n", listenAddr) | ||
if err := http.ListenAndServe(listenAddr, nil); err != nil { | ||
if !errors.Is(err, http.ErrServerClosed) { | ||
log.Fatal(err) | ||
} | ||
} | ||
} |
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,29 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: demo | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 3 | ||
selector: | ||
matchLabels: | ||
app: demo | ||
template: | ||
metadata: | ||
labels: | ||
app: demo | ||
spec: | ||
containers: | ||
- image: ghcr.io/spacelift-io/spacelift-operator-demo:latest | ||
name: demo | ||
ports: | ||
- containerPort: 8888 | ||
name: demo-port | ||
volumeMounts: | ||
- name: secrets | ||
mountPath: /etc/secrets | ||
readOnly: true | ||
volumes: | ||
- name: secrets | ||
secret: | ||
secretName: stack-output-spacelift-operator-demo |
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,10 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: demo | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: demo-port | ||
selector: | ||
app: demo |
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,10 @@ | ||
--- | ||
apiVersion: app.spacelift.io/v1beta1 | ||
kind: Run | ||
spec: | ||
stackName: spacelift-operator-demo | ||
metadata: | ||
name: spacelift-operator-demo | ||
annotations: | ||
argocd.argoproj.io/hook: Sync | ||
argocd.argoproj.io/sync-wave: "-1" |
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,9 @@ | ||
resource "random_string" "random" { | ||
length = 12 | ||
special = true | ||
} | ||
|
||
output "RANDOM_STRING" { | ||
value = random_string.random.result | ||
sensitive = true | ||
} |