Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Next.js SSR Recipe #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
3 changes: 2 additions & 1 deletion cookbook.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
recipes:
- go-github-release
- go-github-release
- next-js-ssr
29 changes: 29 additions & 0 deletions recipes/next-js-ssr/.dunner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
next:
- follow: init
JosephSemrai marked this conversation as resolved.
Show resolved Hide resolved
image: node:10
mounts:
- ".:/src"
commands:
- ["next", "-j$1"]
envs:
- AUTH_SECRET=`$AUTH_SECRET`

next-custom:
- follow: init
image: node:10
mounts:
- ".:/src"
commands:
- ["npm", "-j$1"]
envs:
- AUTH_SECRET=`$AUTH_SECRET`

init:
- name: nextjsspa
image: node:10
mounts:
- ".:/src"
commands:
- ["npm", "install"]
envs:
- AUTH_SECRET=`$AUTH_SECRET`
49 changes: 49 additions & 0 deletions recipes/next-js-ssr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Next.js SSR

This is a [Dunner](https://github.com/leopardslab/dunner) recipe for running your Next.js project (geared towards SSR) in a standardized Node environment.

## Usage

**Run the following command to initialize the Dunner recipe.**

```bash
$ dunner init next-js-ssr
```

This will go ahead and create the Dunner task file (`.dunner.yml`) required to execute Dunner commands.

## Commands

Prior to this, please specify any environment variables that your project uses in a .env file and in the Dunner task file. By default, this recipe will come with configuration for your authentication secret that you just have to specify the value for.

**Run the following to initialize the Next.js project directory.**

```bash
$ dunner do init
```

Run the following command to start the project in a production server

```bash
$ dunner do next start
```

Run the following command to build the application (does not start a server)

```bash
$ dunner do next build
```

Run the following to start the project in a development server

```bash
$ dunner do next
```

## Custom npm Scripts

You can execute the `next-custom` task in order to run any custom npm scripts that you have specified in your project:

```bash
$ dunner do next-custom INSERT_NAME_OF_SCRIPT
```
23 changes: 23 additions & 0 deletions recipes/next-js-ssr/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: next-js-ssr
description: "Dunner recipe for running SSR Next.js projects in a standardized Node environment"
version: "0.1.0"

postInstallMessage: |
This recipe takes in your current Next.js project and will run it in a standardized Node v10 environment.

You can run all of the default Next scripts by executing the name of the script after `dunner do next` as follows

```
$ dunner do next build
```

You can also execute any custom npm script that you have specified by prepending `dunner do next-custom` as follows

```
$ dunner do next-custom lint:fix
JosephSemrai marked this conversation as resolved.
Show resolved Hide resolved
```

Custom Script Syntax:
```
$ dunner do next-custom INSERT_SCRIPT_NAME_HERE
```