Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5cdab36
websites for nitric run
davemooreuws Jan 21, 2025
356647b
wip nitric start for websites
davemooreuws Jan 21, 2025
85062fd
nitric run - single entrypoint with api proxy
davemooreuws Jan 23, 2025
2269b4f
add to spec
davemooreuws Jan 30, 2025
6cfcf3c
websites in dashboard wip
davemooreuws Feb 11, 2025
e2787a3
nitric start reverse proxy dev sites wip
davemooreuws Feb 12, 2025
a2c757b
add more validation and website dashboard info
davemooreuws Feb 13, 2025
c35f442
remove redundant ports config
davemooreuws Feb 13, 2025
8d22c05
add websites to arch diagram
davemooreuws Feb 14, 2025
1d32fbb
fmt
davemooreuws Feb 14, 2025
fa048ea
cleanup of websites arch node
davemooreuws Feb 14, 2025
be80033
add website tests
davemooreuws Feb 14, 2025
ac374b3
install websites before running tests
davemooreuws Feb 14, 2025
7e25dce
update node version for websites
davemooreuws Feb 14, 2025
62ab49e
more test fixes
davemooreuws Feb 14, 2025
9fa1510
adjust test settings
davemooreuws Feb 14, 2025
9ed790d
remove install commands from base site
davemooreuws Feb 14, 2025
0146387
make origin http for test
davemooreuws Feb 14, 2025
8b9874f
sort websites array for dashboard
davemooreuws Feb 25, 2025
169a37d
improve error messages for website dev server
davemooreuws Feb 26, 2025
829e298
update to use latest proto
davemooreuws Feb 26, 2025
1c34081
update mode naming
jyecusch Feb 27, 2025
22979b0
minor refactor
jyecusch Feb 27, 2025
6acdddc
add check for root website
davemooreuws Mar 5, 2025
e3a3ddc
ensure /api is not used as a route
davemooreuws Mar 5, 2025
6f4cf0e
update go mod
davemooreuws Mar 5, 2025
fadf800
update websites node title to CDN
davemooreuws Mar 5, 2025
2ee2718
fix duplicate code
davemooreuws Mar 5, 2025
5196035
cater for website names if in root directory
davemooreuws Mar 5, 2025
b9ed04b
update title to CDN
davemooreuws Mar 5, 2025
f0d1e86
fix arch test
davemooreuws Mar 5, 2025
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: 3 additions & 2 deletions .github/workflows/dashboard-run-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 21
node-version: 22

- name: Setup Go
uses: actions/setup-go@v3
Expand All @@ -44,8 +44,9 @@ jobs:
run: |
cd ${{ github.workspace }}/cli/pkg/dashboard/frontend/test-app
yarn install
yarn install:websites
nitric run --ci &
sleep 15
sleep 25

- name: Run Tests
uses: cypress-io/github-action@v5
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/dashboard-start-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 21
node-version: 22

- name: Lint Dashboard
working-directory: cli/pkg/dashboard/frontend
Expand All @@ -51,7 +51,9 @@ jobs:
run: |
cd ${{ github.workspace }}/cli/pkg/dashboard/frontend/test-app
yarn install
yarn install:websites
nitric start --ci &
sleep 10

- name: Run Tests
uses: cypress-io/github-action@v5
Expand Down
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
28 changes: 27 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var runCmd = &cobra.Command{
LogWriter: logWriter,
LocalConfig: proj.LocalConfig,
MigrationRunner: project.BuildAndRunMigrations,
LocalCloudMode: cloud.LocalCloudModeRun,
LocalCloudMode: cloud.RunMode,
})
tui.CheckErr(err)
runView.Send(local.LocalCloudStartStatusMsg{Status: local.Done})
Expand Down 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
33 changes: 23 additions & 10 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ func createTlsCredentialsIfNotPresent(fs afero.Fs, projectDir string) {
}
}

func runInGoroutine(
fn func(*cloud.LocalCloud, <-chan bool, chan<- project.ServiceRunUpdate, map[string]string) error,
localCloud *cloud.LocalCloud,
stopChan chan bool,
updatesChan chan project.ServiceRunUpdate,
localEnv map[string]string,
) {
go func() {
if err := fn(localCloud, stopChan, updatesChan, localEnv); err != nil {
localCloud.Stop()
tui.CheckErr(err)
}
}()
}

var startCmd = &cobra.Command{
Use: "start",
Short: "Run nitric services locally for development and testing",
Expand Down Expand Up @@ -186,7 +201,7 @@ var startCmd = &cobra.Command{
LogWriter: logWriter,
LocalConfig: proj.LocalConfig,
MigrationRunner: project.BuildAndRunMigrations,
LocalCloudMode: cloud.LocalCloudModeStart,
LocalCloudMode: cloud.StartMode,
})
tui.CheckErr(err)
runView.Send(local.LocalCloudStartStatusMsg{Status: local.Done})
Expand Down Expand Up @@ -221,16 +236,14 @@ var startCmd = &cobra.Command{
}
}()

runInGoroutine(proj.RunServicesWithCommand, localCloud, stopChan, updatesChan, localEnv)

runInGoroutine(proj.RunBatchesWithCommand, localCloud, stopChan, updatesChan, localEnv)

runInGoroutine(proj.RunWebsitesWithCommand, localCloud, stopChan, updatesChan, localEnv)

go func() {
err := proj.RunServicesWithCommand(localCloud, stopChan, updatesChan, localEnv)
if err != nil {
localCloud.Stop()
tui.CheckErr(err)
}
}()
// FIXME: Duplicate code
go func() {
err := proj.RunBatchesWithCommand(localCloud, stopChan, updatesChan, localEnv)
err := proj.RunWebsites(localCloud)
if err != nil {
localCloud.Stop()

Expand Down
25 changes: 12 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ 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-20250305021715-06f92b813ce3
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
)

require (
github.com/Masterminds/semver/v3 v3.3.0
github.com/Masterminds/semver/v3 v3.3.1
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef
github.com/charmbracelet/bubbles v0.16.1
github.com/charmbracelet/bubbletea v0.24.2
Expand All @@ -53,7 +53,7 @@ require (
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/stretchr/testify v1.10.0
github.com/wk8/go-ordered-map/v2 v2.1.8
go.etcd.io/bbolt v1.3.6
golang.org/x/sync v0.10.0
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 @@ -275,18 +275,17 @@ require (
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
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.31.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.32.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.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.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.28.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