Skip to content

Commit

Permalink
Update Project Structure
Browse files Browse the repository at this point in the history
  • Loading branch information
hungnguyenhp committed Feb 2, 2024
1 parent d051c1f commit 9989cab
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 106 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ storage/ci_sessions/*
storage/cookie/*
storage/paygate/*
storage/logs/*
storage/requests/*
storage/tmp/*
public/storage/tmp/*
!/public/storage/tmp/.gitkeep
Expand All @@ -179,6 +180,9 @@ public/storage/tmp/*
!/storage/logs/.gitkeep
!/storage/logs/.htaccess
!/storage/logs/index.html
!/storage/requests/.gitkeep
!/storage/requests/.htaccess
!/storage/requests/index.html
!/storage/tmp/.gitkeep
!/storage/tmp/.htaccess
!/storage/tmp/index.html
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

Change Log được viết theo biểu mẫu tại đây: https://keepachangelog.com/en/1.0.0/

## [1.1.1] - 2024/02/02

### What's Changed

- [x] Add Start Application with Native PHP
- [x] Update Docker PHP 8.0
- [x] CHMOD Bash Script

## [1.1.0] - 2024/01/23

### What's Changed
Expand Down
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-fpm
FROM php:8.0-fpm

# Copy composer.lock and composer.json
# COPY composer.lock composer.json /var/www/
Expand Down Expand Up @@ -69,8 +69,15 @@ RUN apt-get update && apt-get install -y \

RUN pecl install imagick && docker-php-ext-enable imagick

# Install swoole ext
#RUN pecl install swoole \
# && docker-php-ext-enable swoole
# Install mongodb ext
#RUN pecl install mongodb \
# && docker-php-ext-enable mongodb

# Install xdebug
RUN pecl install xdebug && docker-php-ext-enable xdebug
#RUN pecl install xdebug && docker-php-ext-enable xdebug

# remove not necessary files
RUN rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -99,4 +106,10 @@ USER www

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
CMD ["php-fpm"]

# Add a script to monitor changes and update opcache files
COPY ./docker/php/watcher.sh /watcher.sh
RUN chmod +x /watcher.sh

CMD ["/watcher.sh"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ Replace `[my-app-name]` with the name of your new project directory, for example
composer create-project nguyenanhung/codeigniter3-skeleton my-website
```

## Start Application with Native PHP

Start PHP Server:

```shell
composer start
```

Open Service in URL

```shell
http://localhost:8080/
```

## Start Application on Docker

Quickly deploy the application with a pre-built Docker container:
Expand Down
4 changes: 2 additions & 2 deletions app/libraries/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Requests extends SimpleRequests
public function __construct()
{
parent::__construct();
$this->DEBUG = true;
$this->logger_path = __DIR__ . '/../../storage/logs/Requests/';
$this->DEBUG = false;
$this->logger_path = __DIR__ . '/../../storage/requests/';
$this->timeout = 60;
$this->header = array();
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/my_welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<h3>Hi there!</h3>
<p>💡 I'm Hung and I'm a engineering manager in Hanoi, Vietnam.</p>
<p>💻 Currently, I am working as a Engineering Manager at a software company in Hanoi, Vietnam.</p>
<p>💻 My main work is in the fields of Ecommerce Tech, Edutech, Content Management System, DevOps and Project Management</p>
<p>💻 My main work is in the fields of Ecommerce Tech, EdTech, Content Management System, DevOps and Project Management</p>
<p>🌱 I live in a small town in Hanoi with my families, my wife and my son.</p>
<p>💬 am passionated about PHP, Backend, Web, Security, Contribute Open Source and some of the things that</p>
<p>Some of the things that I enjoy include: foods, travel, kungfu and photography. If you'd like to chat about them or anything else, feel free to get in touch with me on<a href="<?= $author->facebook ?>" target="_blank">facebook</a>,<a href="mailto:<?= $author->email ?>">email</a> or<a href="<?= $author->blog ?>" target="_blank">blog</a>.</p>
Expand Down
24 changes: 12 additions & 12 deletions bash/script/clean-releases.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ echo "==================================================="

# Kiểm tra xem có tham số được truyền vào không
if [ -z "$1" ]; then
echo "Cần chỉ định thư mục releases!"
exit 1
echo "Cần chỉ định thư mục releases!"
exit 1
fi

parent_folder="$1"
Expand All @@ -32,16 +32,16 @@ echo "==================================================="

# Giữ lại 3 thư mục có tên lớn nhất, xoá các thư mục khác
for ((i = 0; i < ${#sorted_subfolders[@]}; i++)); do
subfolder=${sorted_subfolders[i]}

# Điều chỉnh số bản releases được giữ lại tại đây
if [ $i -lt 5 ]; then
echo "Giữ lại thư mục: $subfolder"
else
echo "Xoá thư mục: $subfolder với lệnh (sudo rm -rf: $subfolder)"
# Thêm lệnh để xoá thư mục khi bạn đã kiểm tra và chắc chắn rằng script hoạt động đúng
sudo rm -rf "$subfolder"
fi
subfolder=${sorted_subfolders[i]}

# Điều chỉnh số bản releases được giữ lại tại đây
if [ $i -lt 5 ]; then
echo "Giữ lại thư mục: $subfolder"
else
echo "Xoá thư mục: $subfolder với lệnh (sudo rm -rf: $subfolder)"
# Thêm lệnh để xoá thư mục khi bạn đã kiểm tra và chắc chắn rằng script hoạt động đúng
sudo rm -rf "$subfolder"
fi
done

echo "==================================================="
Expand Down
8 changes: 4 additions & 4 deletions bash/script/telegram.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ echo "==================================================="

# Kiểm tra xem có đủ 3 tham số không
if [ $# -ne 3 ]; then
echo "Use: $0 <project_name> <message> <url>"
exit 1
echo "Use: $0 <project_name> <message> <url>"
exit 1
fi

# Lưu các tham số vào biến
Expand All @@ -19,8 +19,8 @@ telegram_bot_token="xxx"

# Gửi tin nhắn tới bot Telegram
curl -s -X POST "https://api.telegram.org/bot$telegram_bot_token/sendMessage" \
-d "chat_id=xxx" \
-d "text=Project: $project_name%0AMessage: $message%0AURL: $url"
-d "chat_id=xxx" \
-d "text=Project: $project_name%0AMessage: $message%0AURL: $url"

echo ""
#echo "Đã gửi thông báo thành công!"
24 changes: 12 additions & 12 deletions bash/script/truncate-log.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ echo "==================================================="

# Kiểm tra xem đã truyền đúng số lượng tham số hay chưa
if [ "$#" -ne 1 ]; then
echo "Sử dụng: $0 <đường dẫn thư mục logs>"
exit 1
echo "Sử dụng: $0 <đường dẫn thư mục logs>"
exit 1
fi

# Lấy đường dẫn đến thư mục logs từ tham số
logs_folder="$1"

# Kiểm tra xem thư mục logs tồn tại
if [ ! -d "$logs_folder" ]; then
echo "Thư mục logs không tồn tại."
exit 1
echo "Thư mục logs không tồn tại."
exit 1
fi

# Mảng tên các tệp log
log_files=(
"access.log"
"error.log"
"access.log"
"error.log"
)

# Duyệt qua từng tệp log và truncate chúng
for log_file in "${log_files[@]}"; do
if [ -f "$logs_folder/$log_file" ]; then
truncate -s 0 "$logs_folder/$log_file"
echo "Đã truncate tệp log $log_file."
else
echo "Tệp log $log_file không tồn tại trong thư mục logs."
fi
if [ -f "$logs_folder/$log_file" ]; then
truncate -s 0 "$logs_folder/$log_file"
echo "Đã truncate tệp log $log_file."
else
echo "Tệp log $log_file không tồn tại trong thư mục logs."
fi
done

echo "Đã truncate các tệp log trong thư mục logs."
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,9 @@
"nguyenanhung/monitor": "Need support for Send Monitor Message to Monitor Service",
"nguyenanhung/markdown": "Parser for Markdown",
"nguyenanhung/basic-firewall": "PHP Basic Firewall - Library providing IP filtering features"
},
"prefer-stable": true,
"scripts": {
"start": "php -S localhost:8080 -t public"
}
}
2 changes: 2 additions & 0 deletions deploy/root_storage/requests/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RewriteEngine On
Options -Indexes
10 changes: 10 additions & 0 deletions deploy/root_storage/requests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>

<p>Directory access is forbidden.</p>

</body>
</html>
Loading

0 comments on commit 9989cab

Please sign in to comment.