mirror of
https://github.com/gabrielkheisa/meme-generator-nodejs
synced 2024-11-21 19:11:42 +07:00
update
This commit is contained in:
parent
010cbefde0
commit
036ae9dc4f
185
README.md
185
README.md
@ -9,5 +9,186 @@ Clone this repository to your local machine:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://repo.gabrielkheisa.xyz/gabrielkheisa/meme-generator-nodejs.git
|
git clone https://repo.gabrielkheisa.xyz/gabrielkheisa/meme-generator-nodejs.git
|
||||||
cd repository_name
|
cd meme-generator-nodejs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 2. Explore docker-compose.yml
|
||||||
|
Take a look at the docker-compose.yml file to understand the services and configurations defined for Docker. Create a Docker external network "meme-generator-net".
|
||||||
|
|
||||||
|
```yml
|
||||||
|
# ./docker-compose.yml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
meme-generator-net:
|
||||||
|
external: true
|
||||||
|
name: "meme-generator-net"
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: adhocore/lemp:8.1
|
||||||
|
# For different app you can use different names. (eg: )
|
||||||
|
container_name: memegenerator
|
||||||
|
volumes:
|
||||||
|
# app source code
|
||||||
|
- ./meme-generator-nodejs:/var/www/html
|
||||||
|
# db data persistence
|
||||||
|
# Here you can also volume php ini settings
|
||||||
|
# - /path/to/zz-overrides:/usr/local/etc/php/conf.d/zz-overrides.ini
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: supersecurepwd
|
||||||
|
MYSQL_DATABASE: appdb
|
||||||
|
MYSQL_USER: dbusr
|
||||||
|
MYSQL_PASSWORD: securepwd
|
||||||
|
# for postgres you can pass in similar env as for mysql but with PGSQL_ prefix
|
||||||
|
networks:
|
||||||
|
- "meme-generator-net"
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_data: {}
|
||||||
|
```
|
||||||
|
### 3. Run the Docker container
|
||||||
|
Run the container using Docker Compose:
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
### 4. Bash into the Container
|
||||||
|
Access the container's terminal/bash, look for it using "docker ps":
|
||||||
|
```bash
|
||||||
|
docker exec -it <container_name> bash
|
||||||
|
```
|
||||||
|
Update the repository:
|
||||||
|
```bash
|
||||||
|
apk update
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Backup SQL table structure
|
||||||
|
Backup the file <b>table_structure_ronaldo.sql</b> from the repository or via terminal by logging into MySQL
|
||||||
|
```bash
|
||||||
|
mysql -u root -p
|
||||||
|
```
|
||||||
|
with the password <b>supersecurepwd</b> . Then, select database <b>appdb</b>
|
||||||
|
```bash
|
||||||
|
use appdb;
|
||||||
|
```
|
||||||
|
and backup the table structure
|
||||||
|
```bash
|
||||||
|
-- phpMyAdmin SQL Dump
|
||||||
|
-- version 5.2.1
|
||||||
|
-- https://www.phpmyadmin.net/
|
||||||
|
--
|
||||||
|
-- Host: app:3306
|
||||||
|
-- Generation Time: Nov 27, 2023 at 10:35 AM
|
||||||
|
-- Server version: 10.6.14-MariaDB
|
||||||
|
-- PHP Version: 8.2.8
|
||||||
|
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
START TRANSACTION;
|
||||||
|
SET time_zone = "+00:00";
|
||||||
|
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8mb4 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Database: `appdb`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `meme_ronaldo`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `meme_ronaldo` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`text` varchar(120) NOT NULL,
|
||||||
|
`value` varchar(9) NOT NULL,
|
||||||
|
`status` varchar(1) NOT NULL DEFAULT '0',
|
||||||
|
`timestamp` timestamp NOT NULL DEFAULT current_timestamp()
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for dumped tables
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `meme_ronaldo`
|
||||||
|
--
|
||||||
|
ALTER TABLE `meme_ronaldo`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for dumped tables
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `meme_ronaldo`
|
||||||
|
--
|
||||||
|
ALTER TABLE `meme_ronaldo`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
|
```
|
||||||
|
### 6. Install Python, video renderer, and all of the requirements
|
||||||
|
For video renderer purposes:
|
||||||
|
```bash
|
||||||
|
apk add make automake gcc g++ subversion python3-dev
|
||||||
|
apk add ffmpeg
|
||||||
|
pip3 install --upgrade pip
|
||||||
|
pip3 install mysql-connector-python==8.0.29
|
||||||
|
pip3 install python-dotenv
|
||||||
|
```
|
||||||
|
### 7. Install Node.js Development or Production Tools
|
||||||
|
In this case, for development only, use nodemon, else use pm2:
|
||||||
|
```bash
|
||||||
|
npm install -g nodemon
|
||||||
|
```
|
||||||
|
### 8. Configure .env File
|
||||||
|
Create a .env file in the root directory and add necessary configurations:
|
||||||
|
```
|
||||||
|
DB_HOST=localhost
|
||||||
|
DB_USER=dbusr
|
||||||
|
DB_PASSWORD=securepwd
|
||||||
|
DB_NAME=appdb
|
||||||
|
PORT=3000
|
||||||
|
```
|
||||||
|
### 9. Start the Node.js App
|
||||||
|
Run the application using npm, in a detached session using Linux screen:
|
||||||
|
```bash
|
||||||
|
apk add screen
|
||||||
|
```
|
||||||
|
Create a screen session for npm:
|
||||||
|
```bash
|
||||||
|
screen
|
||||||
|
```
|
||||||
|
Run the application using npm:
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
Detach from the screen, using <b>CTRL + A</b> then <b>CTRL + D</b>
|
||||||
|
### 10. Run the Python video renderer script
|
||||||
|
Create a screen session for Python video renderer:
|
||||||
|
```bash
|
||||||
|
screen
|
||||||
|
```
|
||||||
|
Execute the Python video renderer script:
|
||||||
|
```bash
|
||||||
|
cd videos
|
||||||
|
python render.py
|
||||||
|
```
|
||||||
|
Detach from the screen, using <b>CTRL + A</b> then <b>CTRL + D</b>
|
||||||
|
### 11. Access the Server Endpoint
|
||||||
|
Navigate to http://localhost:3000 or the configured endpoint in your browser to access the server.
|
||||||
|
|
||||||
|
### Additional Notes:
|
||||||
|
- Modify configurations in docker-compose.yml for custom setups.
|
||||||
|
- Ensure proper permissions and access rights when running docker commands.
|
@ -13,10 +13,12 @@ services:
|
|||||||
container_name: memegenerator
|
container_name: memegenerator
|
||||||
volumes:
|
volumes:
|
||||||
# app source code
|
# app source code
|
||||||
- ./html:/var/www/html
|
- ./meme-generator-nodejs:/var/www/html
|
||||||
# db data persistence
|
# db data persistence
|
||||||
# Here you can also volume php ini settings
|
# Here you can also volume php ini settings
|
||||||
# - /path/to/zz-overrides:/usr/local/etc/php/conf.d/zz-overrides.ini
|
# - /path/to/zz-overrides:/usr/local/etc/php/conf.d/zz-overrides.ini
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: supersecurepwd
|
MYSQL_ROOT_PASSWORD: supersecurepwd
|
||||||
MYSQL_DATABASE: appdb
|
MYSQL_DATABASE: appdb
|
||||||
@ -27,16 +29,6 @@ services:
|
|||||||
- "meme-generator-net"
|
- "meme-generator-net"
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
|
||||||
phpmyadmin:
|
|
||||||
image: phpmyadmin/phpmyadmin
|
|
||||||
container_name: phpmyadmin_memegenerator
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
- PMA_HOST=app
|
|
||||||
- PMA_PORT=3306
|
|
||||||
networks:
|
|
||||||
- "meme-generator-net"
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db_data: {}
|
db_data: {}
|
Loading…
Reference in New Issue
Block a user