diff --git a/README.md b/README.md index 4164e014..dfac77d7 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,31 @@ Stack: Go 1.16+, Node 15+, React 17+, MySQL 8.0+, Redis There are prebuilt binaries/packages available. - Copy .env.example to .env and set variables. You can use https://www.grc.com/passwords.htm to generate a JWT_SECRET. +## More documentation +[Environment Variables](docs/config.md) + ## Setup MySQL create user 'goscrobble'@'%' identified by 'supersecurepass'; create database goscrobble; grant all privileges on goscrobble.* to 'goscrobble'@'%'; -## Local build/run +## Local Development cp .env.example .env # Fill in the blanks - cd web && npm install && REACT_APP_API_URL=http://127.0.0.1:42069 npm start - # In another terminal go mod tidy CGO_ENABLED=0 go run cmd/go-scrobble/*.go + # In another terminal set web/.env.development + cd web && npm install && npm start --env development + Access dev frontend @ http://127.0.0.1:3000 + API @ http://127.0.0.1:42069/api/v1 -## Run local tests - go test test/* - ## Prod deployment We need to build NPM package, and then ship web/build with the binary. + cp .env.example .env # Fill in the blanks - cd web npm install --production && REACT_APP_API_URL=https://goscrobble.com npm run build + cd web npm install --production && npm run build --env production go build -o goscrobble cmd/go-scrobble/*.go ./goscrobble diff --git a/docs/config.md b/docs/config.md index 13ff35b0..02c7d2c3 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,4 +1,6 @@ ## FRONTEND VARS +These are stored in `web/.env.production` and `web/.env.development` + REACT_APP_REGISTRATION_DISABLED=true // Disables registration REACT_APP_API_URL=https://goscrobble.com // Sets API URL @@ -18,4 +20,4 @@ JWT_EXPIRY=86400 // JWT expiry REVERSE_PROXIES=127.0.0.1 // Comma separated list of servers to ignore for IP logs - PORT=42069 // Server port \ No newline at end of file + PORT=42069 // Server port diff --git a/web/.env.development b/web/.env.development new file mode 100644 index 00000000..1fd637b1 --- /dev/null +++ b/web/.env.development @@ -0,0 +1,2 @@ +REACT_APP_API_URL=http://127.0.0.1:42069 +REACT_APP_REGISTRATION_DISABLED=false \ No newline at end of file diff --git a/web/.env.production b/web/.env.production new file mode 100644 index 00000000..18f758e9 --- /dev/null +++ b/web/.env.production @@ -0,0 +1,2 @@ +REACT_APP_API_URL=https://goscrobble.com +REACT_APP_REGISTRATION_DISABLED=true \ No newline at end of file