NuxtJS + NGINX (ssl) + Docker
You can use this out of the box for nuxt ssr however you will need to update NGINX config files if you're using nuxt generate
bash selfsigned.sh --helpselfsigned.sh is an updated bash script that will generate a self signed certificate that can then be imported into Chrome etc.
For usage bash selfsigned.sh --help
You may generate your own certificates (or use pre-existing), update your .env file to reflect the filepath of your certificates.
You will need to create or use a pre-existing site from your hosts file
sudo vi /etc/hostsYou will need to also change the server_name value in the NGINX config file (./config/dev.conf) for both http (80) and https (443)
e.g. server_name nuxtjs-docker.dev; > server_name your_site.dev;
Open your .env and change the value of ENVIRONMENT
e.g. change "dev" to "prod"
You will need to create a new NGINX config file, with a name matching the value of your ENVIRONMENT value.
e.g. ./config/prod.conf
You may copy the contents from ./config/dev.conf
cp ./config/dev.conf ./config/prod.confYou will need to update the server_name value in your new conf file.
cp .env.example .envUpdate your DOTENV with the self signed certicate paths from above.
You can now build your docker and begin installing packages
docker-compose buildYou have two options when wanting to run commands in your docker container
docker-compose run nuxtjs bashwill log you into a containerdocker-compose run nuxtjs npm run generatewill run a singular command
With that in mind, you can use normal nuxtjs commands like so:
# generate a static project
npm run generatenpm run lintYou will need to run npm install the first time you setup docker, this will create your node_modules directory.
npm installnpm install package-name --saveMake sure that you have updated the NGINX config as well as your DOTENV!
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up (optional -d)docker-compose up (optional -d)