Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e931b05
Add embedded static site route
bryphe-coder Jan 14, 2022
e240cd7
Remove unnecessary sentry/intercom integrations for now
bryphe-coder Jan 14, 2022
67feff7
Remove unused import
bryphe-coder Jan 14, 2022
1dcdee7
Update dependencies
bryphe-coder Jan 15, 2022
b516310
Update v2-dev script
bryphe-coder Jan 15, 2022
974df4e
Add dev targets for v2
bryphe-coder Jan 15, 2022
3aa80d6
Add dev scripts to proxy api
bryphe-coder Jan 15, 2022
c2f912a
Add descriptive comment for confusing bash incantation
bryphe-coder Jan 15, 2022
b1fdb32
Use v2-dev instead of v2-dev.sh for ease of use
bryphe-coder Jan 15, 2022
dfc7cac
Exclude dev scripts from coverage
bryphe-coder Jan 15, 2022
6ade6a6
Add test case for embed static
bryphe-coder Jan 15, 2022
6aa66ac
Fix formatting of jest file
bryphe-coder Jan 17, 2022
ccce23a
Use .gitkeep to preserve directory structure; replace embed.go with e…
bryphe-coder Jan 18, 2022
9b770a6
Update Makefile and .gitignore
bryphe-coder Jan 18, 2022
e8d6f76
Simplify proxy APIs for dev server
bryphe-coder Jan 18, 2022
6fe167e
Un-export several CSP types/constants that do not need to be exported
bryphe-coder Jan 18, 2022
7f79897
Add -tag=embed to the gotestsum command
bryphe-coder Jan 18, 2022
735091e
Formatting
bryphe-coder Jan 18, 2022
2b87738
Fix path of .gitkeep file
bryphe-coder Jan 18, 2022
9fdefa5
Fix GITKEEP naming, so go embed doesn't ignore it
bryphe-coder Jan 18, 2022
0f3fe77
Update v2-dev script for new Makefile targets / built binary path
bryphe-coder Jan 18, 2022
e3586aa
Actually add nested GITKEEP file
bryphe-coder Jan 18, 2022
82397c0
Add build tags argument to golangci-lint
bryphe-coder Jan 18, 2022
8046586
Pin ts-node in package.json
bryphe-coder Jan 18, 2022
5ae703a
Update lockfile
bryphe-coder Jan 18, 2022
93f8057
Remove introduced whitespace
bryphe-coder Jan 18, 2022
03a2945
Remove build/go; rename build/ui -> site/out
bryphe-coder Jan 18, 2022
974c654
Remove embed tag completely
bryphe-coder Jan 18, 2022
d9c6aeb
Default CODERV2_HOST to local server on :3000
bryphe-coder Jan 18, 2022
237f83e
Move devbin/v2-dev -> develop.sh
bryphe-coder Jan 18, 2022
3d42ef3
Move dev.ts from site/scripts -> site
bryphe-coder Jan 18, 2022
65d0145
Properly .gitignore front-end site/out
bryphe-coder Jan 18, 2022
8902599
Sort Makefile targets
bryphe-coder Jan 18, 2022
211be9f
Fix dev.ts ignore path for code coverage
bryphe-coder Jan 18, 2022
be9e302
Add missed prettierignore path
bryphe-coder Jan 18, 2022
5441d0c
Alphabetize jest.config.js ignore paths
bryphe-coder Jan 18, 2022
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ yarn-error.log
# Front-end ignore
.next/
site/.next/
coverage/
coverage/

# Build
bin/
site/out/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ yarn-error.log
# Front-end ignore
.next/
site/.next/
site/out/
coverage/
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
bin/coderd:
mkdir -p bin
go build -o bin/coderd cmd/coderd/main.go
.PHONY: bin/coderd

build: site/out bin/coderd
.PHONY: build

# Runs migrations to output a dump of the database.
database/dump.sql: $(wildcard database/migrations/*.sql)
go run database/dump/main.go
Expand Down Expand Up @@ -43,4 +51,9 @@ provisionersdk/proto: provisionersdk/proto/provisioner.proto
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisioner.proto
.PHONY: provisionersdk/proto
.PHONY: provisionersdk/proto

site/out:
yarn build
yarn export
.PHONY: site/out
2 changes: 2 additions & 0 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"cdr.dev/slog"
"github.com/coder/coder/database"
"github.com/coder/coder/site"
"github.com/go-chi/chi"
"github.com/go-chi/render"
)
Expand All @@ -27,5 +28,6 @@ func New(options *Options) http.Handler {
})
})
})
r.NotFound(site.Handler().ServeHTTP)
return r
}
16 changes: 16 additions & 0 deletions develop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

PROJECT_ROOT="$(git rev-parse --show-toplevel)"
cd "${PROJECT_ROOT}"

# Do initial build - a dev build for coderd.
# It's OK that we don't build the front-end before - because the front-end
# assets are handled by the `yarn dev` devserver.
make bin/coderd

# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly
# to kill both at the same time. For more details, see:
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
(trap 'kill 0' SIGINT; CODERV2_HOST=http://127.0.0.1:3000 yarn dev & ./bin/coderd)
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ require (
github.com/hashicorp/terraform-json v0.13.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/justinas/nosurf v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
Expand All @@ -90,6 +91,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/unrolled/secure v1.0.9 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/justinas/nosurf v1.1.1 h1:92Aw44hjSK4MxJeMSyDa7jwuI9GR2J/JCQiaKvXXSlk=
github.com/justinas/nosurf v1.1.1/go.mod h1:ALpWdSbuNGy2lZWtyXdjkYv4edL23oSEgfBT1gPJ5BQ=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/k0kubun/pp v2.3.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
Expand Down Expand Up @@ -1151,10 +1153,13 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/unrolled/secure v1.0.9 h1:BWRuEb1vDrBFFDdbCnKkof3gZ35I/bnHGyt0LB0TNyQ=
github.com/unrolled/secure v1.0.9/go.mod h1:fO+mEan+FLB0CdEnHf6Q4ZZVNqG+5fuLFnP8p0BXDPI=
github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
"<rootDir>/site/**/*.tsx",
"!<rootDir>/site/**/*.stories.tsx",
"!<rootDir>/site/.next/**/*.*",
"!<rootDir>/site/dev.ts",
"!<rootDir>/site/next-env.d.ts",
"!<rootDir>/site/next.config.js",
],
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "NODE_ENV=production next build site",
"build:dev": "next build site",
"dev": "next dev site",
"dev": "ts-node site/dev.ts",
"export": "next export site",
"format:check": "prettier --check '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
"format:write": "prettier --write '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
"test": "jest --selectProjects test",
Expand All @@ -17,18 +18,23 @@
"@material-ui/icons": "4.5.1",
"@material-ui/lab": "4.0.0-alpha.42",
"@testing-library/react": "12.1.2",
"@types/express": "4.17.13",
"@types/jest": "27.4.0",
"@types/node": "14.18.4",
"@types/react": "17.0.38",
"@types/react-dom": "17.0.11",
"@types/superagent": "4.1.14",
"express": "4.17.2",
"http-proxy-middleware": "2.0.1",
"jest": "27.4.7",
"next": "12.0.7",
"prettier": "2.5.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"ts-jest": "27.1.2",
"ts-loader": "9.2.6",
"ts-node": "10.4.0",
"typescript": "4.5.4"
}
},
"dependencies": {}
}
42 changes: 42 additions & 0 deletions site/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import express from "express"
import { createProxyMiddleware } from "http-proxy-middleware"
import next from "next"

const port = process.env.PORT || 8080
const dev = process.env.NODE_ENV !== "production"

let coderV2Host = "http://127.0.0.1:3000"

if (process.env.CODERV2_HOST) {
if (!/^http(s)?:\/\//.test(process.env.CODERV2_HOST)) {
throw new Error("CODERV2_HOST must be http(s)")
} else {
coderV2Host = process.env.CODERV2_HOST
}
}

console.log(`Using CODERV2_HOST: ${coderV2Host}`)

const app = next({ dev, dir: "./site" })
const handle = app.getRequestHandler()

app
.prepare()
.then(() => {
const server = express()
server.use(
"/api",
createProxyMiddleware("/api", {
target: coderV2Host,
ws: true,
secure: false,
changeOrigin: true,
}),
)
server.all("*", (req, res) => handle(req, res))
server.listen(port)
})
.catch((err) => {
console.error(err)
process.exit(1)
})
Loading