Our default starter for GatsbyJS projects at Odd Camp.
https://gatsby-starter-oddcamp.netlify.app
Create .env file when developing locally:
URL=http://localhost:8000
URL is set automatically in Netlify.
The project also include a config for the new Visual Studio Code Remote - Containers system where your editor aswell as the code is inside of a container.
To get this working you need to follow the steps below:
- Install the Remote Development extension and follow the setup guide for the extension.
- On any project that has it setup a popup will show up in the bottom right asking you to re-open it in the container, just click
Re-open in containerand it will start it up. - We don't start the development servers automatically for this variant.
So to start a process you should click on the
Terminaltab in the bottom of the editor and enter the commands you want below. Development server:yarn develop-nBuild:yarn buildandyarn serve-n
Any changes to the dependencies should be run in the editor. To create a new terminal in the container just click the + button.
We provide two ways of developing locally but we recommend using Docker as the default.
- Provide your Github Access Token if you use Private Github packages. Otherwise use blank.
Put
GITHUB_ACCESS_TOKEN=<TOKEN>in.env. - Run
$ docker-compose build - Run
$ docker-compose up(this starts ayarn installandyarn develop-n) - Visit your development environment on localhost:8000.
Testing
- Create a build and serve it by running
$ docker-compose run --rm app ./scripts/build.sh - Visit the build on localhost:9000
- Install dependencies
$ yarn install - Start development server:
$ yarn develop: localhost:8000
Or $ yarn develop-n for sharing the server on your network (192.168.X.X:8000)
Testing
- Make a build
$ yarn build - Serve the build
$ yarn serve: localhost:9000
Or $ yarn serve-n for sharing the server on your network (192.168.X.X:9000)
Note: This is only needed if it's using packages from Github Packages
If a project is using a private package (such as a components package), you can do a change where you put your token in the .env file instead of having it globally on the shell. For that to work you need to put GITHUB_ACCESS_TOKEN=<YOUR TOKEN> in the .env and uncomment the - .env file in docker-compose.yml and rebuild by running docker-compose build --force --no-cache
To get your Token and set the project up:
- Get your Github Access Token here.
- Put
GITHUB_ACCESS_TOKEN=<TOKEN>in the.envfile. - Add
"preinstall": "node ./scripts/append-gha.js",to thescriptshash inpackage.json. This makes sure that the keys are set before running yarn. - Add our
k-deployertoken in the Netlify (or whatever system you use) in theGITHUB_ACCESS_TOKENenvironment variable.