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 --help
selfsigned.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/hosts
You 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.conf
You will need to update the server_name value in your new conf file.
cp .env.example .env
Update your DOTENV with the self signed certicate paths from above.
You can now build your docker and begin installing packages
docker-compose build
You have two options when wanting to run commands in your docker container
docker-compose run nuxtjs bash
will log you into a containerdocker-compose run nuxtjs npm run generate
will run a singular command
With that in mind, you can use normal nuxtjs commands like so:
# generate a static project
npm run generate
npm run lint
You will need to run npm install
the first time you setup docker, this will create your node_modules directory.
npm install
npm install package-name --save
Make 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)