Skip to content

Commit

Permalink
dev: remove nginx
Browse files Browse the repository at this point in the history
We already have Caddy running for HTTPS support. We can use just Caddy
to remove the need to have nginx in our dev environments. This does mean
we won't be using the same reverse proxy as we do in production and for
customers. However, I do not think that changes much in practice.
  • Loading branch information
keegancsmith committed Aug 24, 2020
1 parent ef3f87a commit 1eecf41
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 62 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ storybook-static/
*.pem
*.crt

# Custom dev-specific nginx config
/dev/*.nginx.conf

# tilt files
/dev/tilt/generated-cluster
/dev/tilt/tilt-watch-targets
Expand Down
1 change: 0 additions & 1 deletion dev/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
/config_base.json
/config_combined.json
/config_backup.json
/nginx.pid
20 changes: 16 additions & 4 deletions dev/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
http_port 3088
http_port 3081
auto_https disable_redirects
}

# A bit of monstrosity, since we need to reverse proxy via webpack which then
# reverse proxies to us on HTTP.
#
# Caddy (tls :3443) -> webpack (:3080) -> Caddy (:3081) -> sourcegraph-frontend (:3082)
{$SOURCEGRAPH_HTTPS_DOMAIN}:{$SOURCEGRAPH_HTTPS_PORT} {
tls internal
reverse_proxy localhost:3080
}

# Caddy (:3081) -> sourcegraph-frontend (:3082)
*:3081 {
reverse_proxy localhost:3082
}
{$SOURCEGRAPH_HTTPS_DOMAIN}:{$SOURCEGRAPH_HTTPS_PORT}
tls internal
reverse_proxy localhost:3080
1 change: 0 additions & 1 deletion dev/Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ symbols: symbols
github-proxy: github-proxy
frontend: env CONFIGURATION_MODE=server SITE_CONFIG_ESCAPE_HATCH_PATH=$HOME/.sourcegraph/site-config.json frontend
watch: ./dev/changewatch.sh
nginx: nginx -p . -g 'daemon off;' -c $PWD/dev/nginx.conf 2>&1 | grep -v 'could not open error log file'
caddy: ./dev/caddy.sh run --watch --config=dev/Caddyfile
web: ./node_modules/.bin/gulp --color watch
syntect_server: ./dev/syntect_server.sh
Expand Down
7 changes: 1 addition & 6 deletions dev/caddy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ set -euf -o pipefail

pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null

if [ -n "${NO_CADDY:-}" ]; then
echo Not using Caddy because NO_CADDY is set. SSH support through Caddy will not work.
exit 0
fi

mkdir -p .bin

version="2.0.0"
version="2.1.1"
case "$(go env GOOS)" in
linux)
os="linux"
Expand Down
40 changes: 0 additions & 40 deletions dev/nginx.conf

This file was deleted.

1 change: 0 additions & 1 deletion dev/nginx/body/README

This file was deleted.

2 changes: 1 addition & 1 deletion dev/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export SOURCEGRAPH_HTTPS_PORT="${SOURCEGRAPH_HTTPS_PORT:-"3443"}"
[ -n "${DISABLE_SEARCH_SHARDING-}" ] || export INDEXED_SEARCH_SERVERS="localhost:3070 localhost:3071"

# webpack-dev-server is a proxy running on port 3080 that (1) serves assets, waiting to respond
# until they are (re)built and (2) otherwise proxies to nginx running on port 3081 (which proxies to
# until they are (re)built and (2) otherwise proxies to Caddy running on port 3081 (which proxies to
# Sourcegraph running on port 3082). That is why Sourcegraph listens on 3082 despite the externalURL
# having port 3080.
export SRC_HTTP_ADDR=":3082"
Expand Down
7 changes: 3 additions & 4 deletions doc/dev/local_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Sourcegraph has the following dependencies:
- [PostgreSQL](https://wiki.postgresql.org/wiki/Detailed_installation_guides) (v11 or higher)
- [Redis](http://redis.io/) (v5.0.7 or higher)
- [Yarn](https://yarnpkg.com) (v1.10.1 or higher)
- [NGINX](https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/) (v1.14 or higher)
- [SQLite](https://www.sqlite.org/index.html) tools
- [Golang Migrate](https://github.com/golang-migrate/migrate/) (v4.7.0 or higher)
- [Comby](https://github.com/comby-tools/comby/) (v0.11.3 or higher)
Expand All @@ -93,10 +92,10 @@ The following are two recommendations for installing these dependencies:
brew cask install docker
```

3. Install Go, Node Version Manager, PostgreSQL, Redis, Git, NGINX, golang-migrate, Comby, SQLite tools, and jq with the following command:
3. Install Go, Node Version Manager, PostgreSQL, Redis, Git, golang-migrate, Comby, SQLite tools, and jq with the following command:

```
brew install go yarn redis postgresql git gnu-sed nginx golang-migrate comby sqlite pcre FiloSottile/musl-cross/musl-cross jq watchman
brew install go yarn redis postgresql git gnu-sed golang-migrate comby sqlite pcre FiloSottile/musl-cross/musl-cross jq watchman
```

4. Install the Node Version Manager (`nvm`) using:
Expand Down Expand Up @@ -194,7 +193,7 @@ The following are two recommendations for installing these dependencies:
3. Install dependencies:

```
sudo apt install -y make git-all postgresql postgresql-contrib redis-server nginx libpcre3-dev libsqlite3-dev pkg-config golang-go musl-tools docker-ce docker-ce-cli containerd.io yarn jq
sudo apt install -y make git-all postgresql postgresql-contrib redis-server libpcre3-dev libsqlite3-dev pkg-config golang-go musl-tools docker-ce docker-ce-cli containerd.io yarn jq
# install golang-migrate (you must rename the extracted binary to `golang-migrate` and move the binary into your $PATH)
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.7.0/migrate.linux-amd64.tar.gz | tar xvz
Expand Down
1 change: 0 additions & 1 deletion enterprise/dev/Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ symbols: symbols
github-proxy: github-proxy
frontend: env CONFIGURATION_MODE=server SITE_CONFIG_ESCAPE_HATCH_PATH=$HOME/.sourcegraph/site-config.json frontend
watch: ./dev/changewatch.sh
nginx: nginx -p . -g 'daemon off;' -c $PWD/dev/nginx.conf 2>&1 | grep -v 'could not open error log file'
caddy: ./dev/caddy.sh run --watch --config=dev/Caddyfile
web: ./node_modules/.bin/gulp --color watch
syntect_server: ./dev/syntect_server.sh
Expand Down

0 comments on commit 1eecf41

Please sign in to comment.