Accelerate your next FastAPI Base Project Generator frontend development with NuxtJS, an open source framework making web development simple and powerful.
Make sure to install the dependencies:
# yarn
yarn install
# npm
npm installStart the development server on http://localhost:3000
# yarn
yarn dev
# npm
npm run devBuild the application for production:
# yarn
yarn build
# npm
npm run buildLocally preview production build:
#yarn
yarn preview
# npm
npm run previewCheckout the deployment documentation for more information.
A Docker configuration is also provided. The Dockerfile is divided into four build stages:
build:- Copy files from the repo into the Docker container
- Install dependencies from package.json with Yarn
- Build the Nuxt.js app with server-side rendering (SSR) in standalone mode
run-dev: use the build stage to run the dev server, which can hot-reload within the Docker container if the source code is mountedrun-start: use the build stage to runnuxt start, with all dependencies from the buildrun-minimal: this image is less than 1/6 the size of the others (262 MB vs. 1.72 GB)- Pull a Node.js image running on Alpine Linux
- Copy the built Nuxt.js app from the
buildstage, withoutnode_modules - Install
nuxt-start, with the minimal runtime for Nuxt.js (needed in addition to the inlined dependencies from standalone mode) - Run the
nuxt startcommand using thenuxt-startmodule to start the SSR application
Important note: The main trade-off for the minimal production build is that any NuxtJS modules declared in the modules: section of the nuxt.config.js file must also be specified in the Dockerfile on the yarn add line as shown here (it's not installing from the package.json, which is one reason why it's smaller). To switch from the minimal production build to the full production build, either specify the target build stage in the docker-compose.yml (target: run-start, as is done for the local development configuration here), or push Docker images from each stage to a registry, then specify the appropriate tag to be pulled (with the TAG environment variable, as shown here).
To work with the Docker configuration:
cd /path/to/full-stack-fastapi-postgresql/{{cookiecutter.project_slug}}/frontend
# build and run the development environment with hot-reloading
docker build . --rm --target run-dev -t localhost/whythawk/nuxt-for-fastapi:run-dev
docker run -it -p 3000:3000 -v $(pwd):/app --env-file $(pwd)/.env localhost/whythawk/nuxt-for-fastapi:run-dev
# build and run the minimal production environment
docker build . --rm --target run-minimal -t localhost/whythawk/nuxt-for-fastapi:run-minimal
docker run --env-file $(pwd)/.env -it -p 3000:3000 localhost/whythawk/nuxt-for-fastapi:run-minimalThen browse to http://localhost:3000 to see the homepage.
This project is licensed under the terms of the MIT license.