Skip to content

Commit 8cf7d6f

Browse files
committed
cmd/rofl: Populate compose.yaml with boilerplate content
Based on the feedback from one of our partners, populating compose.yaml with ROFL-specific features (storage, appd, secrets) is a good idea and then let developer remove those, if not needed.
1 parent 4bee075 commit 8cf7d6f

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ build: oasis
1616

1717
build-windows: oasis.exe
1818

19-
oasis: $(shell find . -name "*.go" -type f) go.sum go.mod
19+
oasis: $(shell find . -name "*.go" -type f) $(shell find cmd/rofl/init_artifacts) go.sum go.mod
2020
@$(PRINT) "$(MAGENTA)*** Building Go code...$(OFF)\n"
2121
@$(GO) build -v -o oasis $(GOFLAGS) $(GO_EXTRA_FLAGS)
2222

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
mycontainer:
3+
build: .
4+
image: "docker.io/org_name/image_name" # Always provide FQDN image names!
5+
platform: linux/amd64
6+
volumes:
7+
- /storage/my_container:/root/.my_volume # Persistent per-machine storage.
8+
- /run/rofl-appd.sock:/run/rofl-appd.sock # appd REST API.
9+
environment:
10+
- MY_SECRET_1=${MY_SECRET_1} # See `oasis rofl secret` command.
11+
- MY_SECRET_2=${MY_SECRET_2}

cmd/rofl/mgmt.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bufio"
55
"bytes"
66
"context"
7+
_ "embed"
78
"encoding/json"
89
"errors"
910
"fmt"
@@ -43,6 +44,9 @@ var (
4344
appTEE string
4445
appKind string
4546

47+
//go:embed init_artifacts/compose.yaml
48+
initArtifactCompose []byte
49+
4650
initCmd = &cobra.Command{
4751
Use: "init [<name>] [--tee TEE] [--kind KIND]",
4852
Short: "Initialize a ROFL app manifest",
@@ -709,12 +713,10 @@ func detectOrCreateComposeFile() string {
709713
}
710714

711715
filename := "compose.yaml"
712-
f, err := os.OpenFile(filename, os.O_RDONLY|os.O_CREATE, 0o644)
713-
if err != nil {
716+
if err := os.WriteFile(filename, []byte(initArtifactCompose), 0o644); err != nil {
714717
return ""
715718
}
716719

717-
f.Close()
718720
return filename
719721
}
720722

0 commit comments

Comments
 (0)