Use nvm (Node Version Manager) to install and manage the required versions of Node.js and npm:
-
Install nvm: If nvm isn't installed, follow the official installation guide.
Or, run this commands:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# These should pick up the nvm command source ~/.bashrc
-
Install Node.js (v18 or higher) and npm (latest):
This will install the latest long-term support (LTS) version of Node.js and the latest compatible npm version.
nvm install --lts nvm use --lts
-
Verify installation:
node -v npm -v
First, clone the project repository to your local machine:
git clone https://github.com/vlad1slove1/landing.git
cd landing
Next, install the required dependencies using npm:
npm install
Copy or rename the .env.example file to .env:
cp .env.example .env
Then open the .env file and set the appropriate values for your environment variables:
NEXT_PUBLIC_TELEGRAM_BOT_TOKEN=personal bot token
NEXT_PUBLIC_TELEGRAM_CHAT_ID=chat_id for specific telegram group
NEXT_PUBLIC_SITE_URL=production url for backend utilities
Save the .env file after updating all the variables
Once the dependencies are installed, run the development server:
npm run dev
The app will now be running on http://localhost:3000
To check the code for style and potential issues, run the linting command:
npm run lint
To create a production build of the project, run the following command:
npm run build
Build the image:
docker build -t landing .
Run the container:
docker run -p 3000:3000 landing
Now app is up and running on http://localhost:3000
Create a new service file in /etc/systemd/system/:
sudo nano /etc/systemd/system/landing.service
Add the following content:
[Unit]
Description=landing container
After=docker.service
Wants=network-online.target docker.socket
Requires=docker.socket
[Service]
Restart=always
ExecStart=/usr/bin/docker run -p 3000:3000 landing
ExecStop=/usr/bin/docker stop landing
[Install]
WantedBy=multi-user.target
Enable and start the service using:
sudo systemctl daemon-reload
sudo systemctl enable landing.service
sudo systemctl start landing.service
Verify that the service is running:
sudo systemctl status landing.service
Now the Dockerized app is running as a systemd service!