7e12997af6
I wrote a [script](https://github.com/j0lv3r4/dependency-version-updater) to update dependencies recursively in `package.json` files, e.g.: ``` $ node index.js --path="./examples" --dependencies="react=^16.7.0,react-dom=^16.7.0" ``` This PR contains the result against the examples folder. |
||
---|---|---|
.. | ||
src | ||
.env.example | ||
.eslintignore | ||
.eslintrc.json | ||
.prettierrc | ||
docker-compose.deploy.yml | ||
docker-compose.dev.yml | ||
docker-compose.serve.yml | ||
docker-compose.yml | ||
Dockerfile | ||
firebase.json | ||
LICENSE | ||
next.config.js | ||
package.json | ||
README.md |
With Firebase Hosting and Docker example
How to use
Using create-next-app
Execute create-next-app
with Yarn or npx to bootstrap the example:
npx create-next-app --example with-firebase-hosting-and-docker with-firebase-hosting-and-docker-app
# or
yarn create next-app --example with-firebase-hosting-and-docker with-firebase-hosting-and-docker-app
Download manually
Download the example:
curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-firebase-hosting-and-docker
cd with-firebase-hosting-and-docker
Set up firebase:
- create a project through the firebase web console
- grab the projects ID from the web consoles URL: https://console.firebase.google.com/project/
- update the
.env
with your FB_PROJECTID and FIREBASE_TOKEN ( see .env.example ) - ADD
serviceAccountKey.json
to your project root
Dev next
yarn docker:dev
open http://localhost:5000
Firebase serve
yarn docker:serve
open http://localhost:3000
Firebase deploy
yarn docker:deploy
The idea behind the example
The goal is to host the Next.js app on Firebase Cloud Functions with Firebase Hosting rewrite rules so our app is served from our Firebase Hosting URL, with docker support for a consistent development environment. Each individual page
bundle is served in a new call to the Cloud Function which performs the initial server render. Docker is entirely dedicated for local development and the deployment process and that Firebase itself will not leverage Docker itself.
This is based off of the work of @jthegedus in the with-firebase-hosting example.
If you're having issues, feel free to tag @sampsonjoliver in the issue you create on the next.js repo
Important
- The empty
placeholder.html
file is so Firebase Hosting does not error on an emptypublic/
folder and still hosts at the Firebase project URL. firebase.json
outlines the catchall rewrite rule for our Cloud Function.- The Firebase predeploy hooks defined in
firebase.json
will handle linting and compiling of the next app and the functions sourceswhenfirebase deploy
is invoked. The only scripts you should need aredocker:dev
,docker:serve
anddocker:deploy
.