1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-firebase-hosting-and-docker
2018-12-10 22:05:53 +01:00
..
src Fix linting 2018-12-10 22:05:53 +01:00
.env.example Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
.eslintignore Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
.eslintrc.json Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
.prettierrc Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
docker-compose.deploy.yml Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
docker-compose.dev.yml Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
docker-compose.serve.yml Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
docker-compose.yml Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
Dockerfile Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
firebase.json Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
LICENSE Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
next.config.js Fix linting 2018-12-10 22:05:53 +01:00
package.json Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00
README.md Create with-firebase-hosting-and-docker example (#5373) 2018-12-10 16:19:57 +01:00

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:

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 empty public/ 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 sourceswhen firebase deploy is invoked. The only scripts you should need are docker:dev, docker:serve and docker:deploy.