Deploy a commercial Next.js application with pkg and docker.
Medium article: Deploy a commercial Next.js application with pkg and docker
https://nextjs-pkg-docker-alpine.now.sh/
$ yarn install
$ yarn run dev
# Build pkg
$ yarn run build
$ yarn run pkg
# Execute the binary
NODE_ENV=production ./pkg/nextjs-pkg-docker-alpine
$ docker build -t nextjs-pkg-docker-alpine .
$ docker run --rm -it \
-p 3003:3003 \
-e "PORT=3003" \
-e "API_URL=https://API_URL.com" \
nextjs-pkg-docker-alpine
Note: It might take some time to
fetch base Node.js binaries to PKG_CACHE_PATH
during the pkg process.
$ now --docker
MIT © Michael Hsu