Giter VIP home page Giter VIP logo

nuxtjs-docker's Introduction

nuxtjs-docker

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

Getting Started

Generate SSL certificates (DEV ONLY)

Ubuntu users

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

Everyone else

You may generate your own certificates (or use pre-existing), update your .env file to reflect the filepath of your certificates.

NGINX Config

For Dev

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;

For Prod (or other)

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.

Copy DOTENV

cp .env.example .env

Update your DOTENV with the self signed certicate paths from above.

Docker Build

You can now build your docker and begin installing packages

docker-compose build

Nuxt & NPM commands

You have two options when wanting to run commands in your docker container

  1. docker-compose run nuxtjs bash will log you into a container
  2. docker-compose run nuxtjs npm run generate will run a singular command

With that in mind, you can use normal nuxtjs commands like so:

Generate

# generate a static project
npm run generate

Lint

npm run lint

Install

You will need to run npm install the first time you setup docker, this will create your node_modules directory.

npm install

Installing New Packages

npm install package-name --save

Running NuxtJS

Make sure that you have updated the NGINX config as well as your DOTENV!

Run Nuxt in Dev Mode

docker-compose -f docker-compose.yml -f docker-compose.dev.yml up (optional -d)

Run Nuxt in Prod Mode

docker-compose up (optional -d)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.