diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 065a803..cd7c2a2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,6 +4,12 @@ FROM mcr.microsoft.com/devcontainers/typescript-node:0-18 # Install wget if not already installed RUN apt-get update && apt-get install -y wget +# Install Gatsby CLI and Yarn +RUN npm install -g gatsby-cli yarn +# Let's get the latest version of Yarn +RUN corepack enable +RUN yarn set version berry + # Download .zshrc from remote address # RUN sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" USER node @@ -11,7 +17,7 @@ RUN wget https://raw.githubusercontent.com/Riverscapes/environment/master/nar-ys RUN wget https://raw.githubusercontent.com/Riverscapes/environment/master/.aliases -O ~/.aliases RUN wget https://raw.githubusercontent.com/Riverscapes/environment/master/.zshrc -O ~/.zshrc - -# set memory to 6Gb so that Gatsby has a chance -ENV NODE_OPTIONS=--max-old-space-size=6144 +# set memory to 8Gb so that Gatsby has a chance +ENV NODE_OPTIONS=--max-old-space-size=8192 +ENV GATSBY_CPU_COUNT=2 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 179c962..5dc18c7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,16 @@ { "dockerFile": "Dockerfile", + "name": "Gatsby Docs Dev Container", + "waitFor": "onCreateCommand", + // On container creation, install dependencies. + "postCreateCommand": "yarn install", + // Build and run the dev site on container start. + "postAttachCommand": "gatsby build; gatsby serve -H 0.0.0.0 -p 8000", "customizations": { "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "zsh" + }, "extensions": [ "GitHub.copilot", "GitHub.copilot-chat", @@ -14,7 +23,15 @@ ] } }, - "postCreateCommand": [ - "yarn install" + // Trigger actions on ports. More info: https://containers.dev/implementors/json_reference/#port-attributes + "portsAttributes": { + "8000": { + "label": "Application", + "onAutoForward": "openPreview" + } + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 8000 ] } \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b30e927..e2905da 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,5 @@ -name: Gatsby Publish - +name: Gatsby GHPages Publish +# NOTE: This is designed to work for a site living in the /docs folder. You'll need to make changes if it is not. on: push: branches: @@ -28,26 +28,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Detect package manager - id: detect-package-manager - run: | - if [ -f "${{ github.workspace }}/yarn.lock" ]; then - echo "manager=yarn" >> $GITHUB_OUTPUT - echo "command=install" >> $GITHUB_OUTPUT - exit 0 - elif [ -f "${{ github.workspace }}/package.json" ]; then - echo "manager=npm" >> $GITHUB_OUTPUT - echo "command=ci" >> $GITHUB_OUTPUT - exit 0 - else - echo "Unable to determine package manager" - exit 1 - fi + - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: "18" - cache: ${{ steps.detect-package-manager.outputs.manager }} + node-version-file: ./.nvmrc + cache-dependency-path: ./package.json + cache: yarn + + - name: Get correct version of Yarn + run: corepack enable; yarn set version berry - name: Setup Pages id: pages @@ -58,23 +48,26 @@ jobs: # You may remove this line if you want to manage the configuration yourself. static_site_generator: gatsby + - name: Restore cache uses: actions/cache@v3 with: path: | - public - .cache + ./public + ./.cache key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} restore-keys: | ${{ runner.os }}-gatsby-build- - name: Install dependencies - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} + working-directory: . + run: yarn install - name: Build with Gatsby + working-directory: . env: PREFIX_PATHS: 'true' - run: ${{ steps.detect-package-manager.outputs.manager }} run build + run: yarn run build - name: Upload artifact uses: actions/upload-pages-artifact@v1 diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml deleted file mode 100644 index 11e560c..0000000 --- a/.github/workflows/validate.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Validate - -on: - push: - branches: - - dev - pull_request: - branches: - - dev - - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - - -# Default to bash -defaults: - run: - shell: bash - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Detect package manager - id: detect-package-manager - run: | - if [ -f "${{ github.workspace }}/yarn.lock" ]; then - echo "manager=yarn" >> $GITHUB_OUTPUT - echo "command=install" >> $GITHUB_OUTPUT - exit 0 - elif [ -f "${{ github.workspace }}/package.json" ]; then - echo "manager=npm" >> $GITHUB_OUTPUT - echo "command=ci" >> $GITHUB_OUTPUT - exit 0 - else - echo "Unable to determine package manager" - exit 1 - fi - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: "18" - cache: ${{ steps.detect-package-manager.outputs.manager }} - - name: Setup Pages - id: pages - uses: actions/configure-pages@v3 - with: - # Automatically inject pathPrefix in your Gatsby configuration file. - # - # You may remove this line if you want to manage the configuration yourself. - static_site_generator: gatsby - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - public - .cache - key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} - restore-keys: | - ${{ runner.os }}-gatsby-build- - - name: Install dependencies - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} - - name: Build with Gatsby - env: - PREFIX_PATHS: 'true' - run: ${{ steps.detect-package-manager.outputs.manager }} run build - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - path: ./public