Skip to content

Commit c476181

Browse files
authored
Merge pull request #517 from oasisprotocol/matevz/feature/populate-compose
cmd/rofl: Populate compose.yaml with boilerplate content
2 parents 4ba9f1c + 075eb21 commit c476181

3 files changed

Lines changed: 20 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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
- my-volume:/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}
12+
13+
volumes:
14+
my-volume:

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, initArtifactCompose, 0o644); err != nil { //nolint: gosec
714717
return ""
715718
}
716719

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

0 commit comments

Comments
 (0)