Skip to content

Running on your machine

Minjun Kim edited this page Mar 2, 2020 · 1 revision

This document will guide you through how to run velog server on your own machine for development or testing purposes.

Prerequisites

Following tools should be installed before running velog server

Clone the project

git clone https://github.com/velopert/velog-server.git

Prepare PostgreSQL Database

cd ./velog-server/docker/postgresql
docker-compose up -d
# To close database server enter following command:
# docker-compose down

If you run your PostgreSQL server, the database will be initialized with following configuration:

Name Value
Host localhost
Port 5432
Database velog
User velog
Password velogpw

Information above is already set in .env.development so there is no need to edit your .env.development file

Prepare Redis

Redis server is only required for cache system of server side rendering. It is not mandatory to run the server, however, you will see error messages repeatedly on server console when redis is not running.

cd ./velog-server/docker/redis
docker-compose up -d
# To close database server enter following command:
# docker-compose down

ElasticSearch

ElasticSearch is used as search engine of velog.

cd ./velog-server/docker/search
docker-compose up -d

After running ElasticSearch server, make following request via any HTTP client (e.g. Postman)

PUT http://localhost:9200/posts

{
    "settings": {
        "analysis": {
            "tokenizer": {
                "korean_nori_tokenizer": {
                    "type": "nori_tokenizer",
                    "decompound_mode": "mixed"
                }
            },
            "analyzer": {
                "nori_analyzer": {
                    "type": "custom",
                    "tokenizer": "korean_nori_tokenizer",
                    "filter": [
                        "nori_posfilter"
                    ]
                }
            },
            "filter": {
                "nori_posfilter": {
                    "type": "nori_part_of_speech",
                    "stoptags": [
                        "E",
                        "IC",
                        "J",
                        "MAG",
                        "MM",
                        "NA",
                        "NR",
                        "SC",
                        "SE",
                        "SF",
                        "SH",
                        "SL",
                        "SN",
                        "SP",
                        "SSC",
                        "SSO",
                        "SY",
                        "UNA",
                        "UNKNOWN",
                        "VA",
                        "VCN",
                        "VCP",
                        "VSV",
                        "VV",
                        "VX",
                        "XPN",
                        "XR",
                        "XSA",
                        "XSN",
                        "XSV"
                    ]
                }
            }
        }
    },
    "mappings": {
        "properties": {
            "title": {
                "type": "text",
                "analyzer": "nori_analyzer",
                "fields": {
                    "raw": {
                        "type": "text"
                    }
                }
            },
            "body": {
                "type": "text",
                "analyzer": "nori_analyzer",
                "fields": {
                    "raw": {
                        "type": "text"
                    }
                }
            }
        }
    }
}

Install JavaScript dependencies

cd ./velog-server/
yarn install

Run server

yarn dev