Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliyun deploy #7

Merged
merged 4 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.17 as builder

ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct

WORKDIR /app

COPY . .

RUN GOOS=linux GOARCH=amd64 go build -o kcl-playground


FROM kusionstack/kusion:v0.7.2

WORKDIR /app

COPY --from=builder /app/kcl-playground .

EXPOSE 2022


CMD ["./kcl-playground -deploy"]
26 changes: 16 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package main

import (
"flag"
"fmt"
"os/exec"
"runtime"
Expand All @@ -14,17 +15,22 @@ import (
)

func main() {
addr := "localhost:2022"
fmt.Printf("listen at http://%s\n", addr)

go func() {
time.Sleep(time.Second * 2)
openBrowser(addr)
}()

play.Run(addr, &play.Option{
deploy_mode := flag.Bool("deploy", false, "Whether is deploy mode")
flag.Parse()
opt := play.Option{
PlayMode: true,
})
}
if *deploy_mode {
play.Run(":80", &opt)
} else {
addr := "localhost:2023"
fmt.Printf("listen at http://%s\n", addr)
go func() {
time.Sleep(time.Second * 2)
openBrowser(addr)
}()
play.Run(addr, &opt)
}
}

func openBrowser(url string) error {
Expand Down