Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

reply2future/node-blog

Repository files navigation

Node Blog

Build Status Coverage Status Commitizen friendly

A blog use Node.js,lowdb and deployed with docker.Occupies less resources and simple.

System requirement

  • docker
    • docker>=17.0-ce
    • docker-compose>=1.6
  • Node.js
    • node>=16
    • npm>=8

Usage

If you want to deploy automatically, you could refer to my CI/CD

Configuration

Using the environment variables to configure the service.

ADMIN_USER:                         // the username to login the blog administrator beckend
ADMIN_PWD:                          // the password to login the blog, use the `MD5` string
COOKIE_SECRET: 
SESSION_SECRET: 
MAIL_HOST:                          // error mail host
MAIL_USER:                          // error mail user
MAIL_PASS:                          // error mail password
MAIL_FROM:                          // error mail from
MAIL_TO:                            // error mail to notify `receiver`
GOOGLE_ANALYTICS:                   // use google analytics or not, boolean type, default `false`
GOOGLE_ANALYTICS_ID:                // if use google analytics, set the gid, such as `UA-152095536-1`
DISQUS:                             // use disqus comment or not, boolean type, default `false`
DISQUS_NAME:                        // if use disqus comment, set the name, such as `reply2future-pw`

# for rss feed https://www.npmjs.com/package/rss to find more details
RSS_SITE_URL:                       // your website name like https://blog.reply2future.pw
RSS_TITLE:                          // for rss feed title
RSS_DESCRIPTION:                    // for rss feed description
RSS_WEB_MASTER:                     // optional
RSS_COPYRIGHT:                      // optional
RSS_LANGUAGE:                       // optional

Launch

There are two ways to deploy the service: npm command and docker-compose.

npm command

  1. Set the environment variable
  2. Run below command on the root of project.

npm start

docker-compose

  1. Rename the file docker-compose.yml.template to docker-compose.yml
  2. Build your image and push it to the image registry, and you could refer to the command npm run build-img:linux of package.json.
  3. Replace the environment variable of docker-compose.yml, such as ${ADMIN_USER}, and you could use envsubst command to do it quckily.
  4. Run below command on the same directory of the docker-compose.yml.

docker-compose up -d


All done! Check http://localhost:3000

MORE

Create your db directory to store your data,and see docker-compose.yml volumes settings.

Test

npm test

Demo

My Blog

Reference

1.Dockerizing a Node.js web app 2.Manage data in containers