rsnext/examples/with-docker-multi-env
Steven 9f9214abe5
Updated create-next-app docs to include pnpm usage (#35755)
This PR updates the docs and examples for `create-next-app` to include pnpm usage.

The following script was used to update every example README:

```js
const fs = require('fs')
const examples = fs.readdirSync('./examples')

for (let example of examples) {
    const filename = `./examples/${example}/README.md`
    const markdown = fs.readFileSync(filename, 'utf8')
    const regex = new RegExp(`^yarn create next-app --example (.*)$`, 'gm')
    const output = markdown.replace(regex, (yarn, group) => {
        const pnpm = `pnpm create next-app -- --example ${group}`
        return `${yarn}\n# or\n${pnpm}`
    })
    fs.writeFileSync(filename, output)
}
```
2022-03-30 21:03:21 +00:00
..
docker [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
pages [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
public [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
styles [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
.dockerignore Add .git to .dockerignore in docker examples (#34628) 2022-02-21 21:53:56 +01:00
.env [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
.env.development.sample [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
.env.production.sample [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
.env.staging.sample [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
.gitignore [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
Makefile [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
next.config.js [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
package.json [New Example] with docker - multiple deployment environments (#34015) 2022-02-05 18:13:01 +00:00
README.md Updated create-next-app docs to include pnpm usage (#35755) 2022-03-30 21:03:21 +00:00

With Docker - Multiple Deployment Environments

This examples shows how to use Docker with Next.js and deploy to multiple environment with different env values. Based on the deployment documentation.

How to use

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example with-docker-multi-env nextjs-docker-multi-env
# or
yarn create next-app --example with-docker-multi-env nextjs-docker-multi-env
# or
pnpm create next-app -- --example with-docker-multi-env nextjs-docker-multi-env

Enter the values in the .env.development.sample, .env.staging.sample, .env.production.sample files to be used for each environments.

Using Docker and Makefile

Development environment - for doing testing

make build-development
make start-development

Open http://localhost:3001

Staging environment - for doing UAT testing

make build-staging
make start-staging

Open http://localhost:3002

Production environment - for users

make build-production
make start-production

Open http://localhost:3003

Running Locally

First, run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file.

API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.js.

The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.