hohoaisan / simple-dockerized-nextjs-mssql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple dockerized Next.js & MSSQL with live reload enabled

Purpose

  • This is just a simple config intended for practicing writing Dockerfile and Docker Compose config

Prerequisites

How to use

Production

  1. Clone this repository git clone https://github.com/hohoaisan/simple-dockerized-nextjs-mssql.git
  2. Change your terminal working directory to cloned folder cd simple-dockerized-nextjs-mssql
  3. Simply run docker-compose up and wait for it (for the first time, Docker has to pull heavy images from Docker Hub, so the time is suprisingly longer than the next time you build this)
  4. Open http://locahost:3000 on the browser to view the result

Developing with live reload enabled

Notice: Live reloading only works if the original files are stored in the Linux filesystem (reason), so basically when you make changes to the source code in Windows folder, it'll not work, I recommend clonning and running this in WSL2.

  1. Clone this repository git clone https://github.com/hohoaisan/simple-dockerized-nextjs-mssql.git
  2. Change your terminal working directory to cloned folder cd simple-dockerized-nextjs-mssql
  3. Change the config (database name/password - make sure nextjs and mssql have the same config, ports, uncomment command: yarn dev in nextjs config to override production build
  4. Run docker-compose up
  5. Make changes to the source code and live reload will do the rest for you
  6. Open http://locahost:3000 on the browser to view the result

Since you want to stop the project, change your terminal working directory to cloned folder:

  • docker-compose stop or just Ctrl+C in the console to stop running containers
  • docker-compose down to stop (if running) and remove all containers

And docker-compose start to start containers again (if they were not removed) without rebuilding the containers from images

About


Languages

Language:JavaScript 53.7%Language:CSS 29.8%Language:Shell 9.2%Language:Dockerfile 5.7%Language:TSQL 1.5%