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

feat: static websites #849

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ var specCmd = &cobra.Command{
batchRequirements, err := proj.CollectBatchRequirements()
tui.CheckErr(err)

websiteRequirements, err := proj.CollectWebsiteRequirements()
tui.CheckErr(err)

additionalEnvFiles := []string{}

if debugEnvFile != "" {
Expand All @@ -115,7 +118,7 @@ var specCmd = &cobra.Command{
envVariables = map[string]string{}
}

spec, err := collector.ServiceRequirementsToSpec(proj.Name, envVariables, serviceRequirements, batchRequirements)
spec, err := collector.ServiceRequirementsToSpec(proj.Name, envVariables, serviceRequirements, batchRequirements, websiteRequirements)
tui.CheckErr(err)

migrationImageContexts, err := collector.GetMigrationImageBuildContexts(serviceRequirements, batchRequirements, fs)
Expand Down
26 changes: 26 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@ var runCmd = &cobra.Command{
tui.CheckErr(err)
}

websiteBuildUpdates, err := proj.BuildWebsites(loadEnv)
tui.CheckErr(err)

if isNonInteractive() {
fmt.Println("building project websites")
for update := range websiteBuildUpdates {
for _, line := range strings.Split(strings.TrimSuffix(update.Message, "\n"), "\n") {
fmt.Printf("%s [%s]: %s\n", update.ServiceName, update.Status, line)
}
}
} else {
prog := teax.NewProgram(build.NewModel(websiteBuildUpdates, "Building Websites"))
// blocks but quits once the above updates channel is closed by the build process
_, err = prog.Run()
tui.CheckErr(err)
}

// Run the app code (project services)
stopChan := make(chan bool)
updatesChan := make(chan project.ServiceRunUpdate)
Expand Down Expand Up @@ -179,6 +196,15 @@ var runCmd = &cobra.Command{
}
}()

go func() {
err := proj.RunWebsites(localCloud)
if err != nil {
localCloud.Stop()

tui.CheckErr(err)
}
}()

tui.CheckErr(err)
// FIXME: This is a hack to get labelled logs into the TUI
// We should refactor the system logs to be more generic
Expand Down
24 changes: 22 additions & 2 deletions cmd/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ var stackUpdateCmd = &cobra.Command{
batchRequirements, err := proj.CollectBatchRequirements()
tui.CheckErr(err)

websiteRequirements, err := proj.CollectWebsiteRequirements()
tui.CheckErr(err)

additionalEnvFiles := []string{}

if envFile != "" {
Expand All @@ -240,13 +243,13 @@ var stackUpdateCmd = &cobra.Command{
envVariables["NITRIC_BETA_PROVIDERS"] = "true"
}

spec, err := collector.ServiceRequirementsToSpec(proj.Name, envVariables, serviceRequirements, batchRequirements)
spec, err := collector.ServiceRequirementsToSpec(proj.Name, envVariables, serviceRequirements, batchRequirements, websiteRequirements)
tui.CheckErr(err)

migrationImageContexts, err := collector.GetMigrationImageBuildContexts(serviceRequirements, batchRequirements, fs)
tui.CheckErr(err)
// Build images from contexts and provide updates on the builds

// Build images from contexts and provide updates on the builds
if len(migrationImageContexts) > 0 {
migrationBuildUpdates, err := project.BuildMigrationImages(fs, migrationImageContexts, !noBuilder)
tui.CheckErr(err)
Expand Down Expand Up @@ -274,6 +277,23 @@ var stackUpdateCmd = &cobra.Command{
}
}

websiteBuildUpdates, err := proj.BuildWebsites(envVariables)
tui.CheckErr(err)

if isNonInteractive() {
fmt.Println("building project websites")
for update := range websiteBuildUpdates {
for _, line := range strings.Split(strings.TrimSuffix(update.Message, "\n"), "\n") {
fmt.Printf("%s [%s]: %s\n", update.ServiceName, update.Status, line)
}
}
} else {
prog := teax.NewProgram(build.NewModel(websiteBuildUpdates, "Building Websites"))
// blocks but quits once the above updates channel is closed by the build process
_, err = prog.Run()
tui.CheckErr(err)
}

providerStdout := make(chan string)

// Step 4. Start the deployment provider server
Expand Down
10 changes: 10 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ var startCmd = &cobra.Command{
}
}()

// FIXME: Duplicate code
go func() {
err := proj.RunWebsitesWithCommand(localCloud, stopChan, updatesChan, localEnv)
if err != nil {
localCloud.Stop()

tui.CheckErr(err)
}
}()

// FIXME: This is a hack to get labelled logs into the TUI
// We should refactor the system logs to be more generic
systemChan := make(chan project.ServiceRunUpdate)
Expand Down
25 changes: 11 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ replace github.com/mattn/go-ieproxy => github.com/darthShadow/go-ieproxy v0.0.0-
require github.com/golangci/golangci-lint v1.61.0

require (
github.com/AlecAivazis/survey/v2 v2.3.6
github.com/asdine/storm v2.1.2+incompatible
github.com/aws/aws-sdk-go v1.44.175 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand All @@ -23,12 +22,12 @@ require (
github.com/hashicorp/consul/sdk v0.13.0
github.com/hashicorp/go-getter v1.6.2
github.com/hashicorp/go-version v1.7.0
github.com/nitrictech/nitric/core v0.0.0-20241003062412-76ea6275fb0b
github.com/nitrictech/nitric/core v0.0.0-20250123074029-0306df1e20ae
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.8.1
github.com/valyala/fasthttp v1.55.0
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
google.golang.org/grpc v1.66.0
gopkg.in/yaml.v2 v2.4.0
Expand All @@ -52,11 +51,12 @@ require (
github.com/olahol/melody v1.1.3
github.com/robfig/cron/v3 v3.0.1
github.com/samber/lo v1.38.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.11.0
github.com/stretchr/testify v1.9.0
github.com/wk8/go-ordered-map/v2 v2.1.8
go.etcd.io/bbolt v1.3.6
golang.org/x/sync v0.8.0
golang.org/x/sync v0.10.0
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -115,7 +115,7 @@ require (
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/firefart/nonamedreturns v1.0.5 // indirect
Expand Down Expand Up @@ -173,7 +173,6 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/julz/importas v0.1.0 // indirect
github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kisielk/errcheck v1.7.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.5 // indirect
github.com/klauspost/compress v1.17.9 // indirect
Expand All @@ -197,7 +196,6 @@ require (
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mgechev/revive v1.3.9 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down Expand Up @@ -238,7 +236,6 @@ require (
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/securego/gosec/v2 v2.21.2 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sivchari/tenv v1.10.0 // indirect
github.com/sonatard/noctx v0.0.2 // indirect
Expand Down Expand Up @@ -282,14 +279,14 @@ require (
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.24.0 // indirect
golang.org/x/tools v0.27.0 // indirect
google.golang.org/api v0.196.0 // indirect
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed // indirect
Expand Down
Loading
Loading