This commit is contained in:
Havoc420Mac 2025-04-05 17:26:48 +08:00
parent 7fdf9e1079
commit 3a7ac8ccc6
9 changed files with 1 additions and 351 deletions

View File

@ -15,9 +15,8 @@ COPY . .
# 设置环境变量以确保静态编译 # 设置环境变量以确保静态编译
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
# 构建静态链接的二进制文件 # 构建静态链接的二进制文件
RUN go build -a -o myapp . RUN go build -ldflags="-s -w" -a -o myapp .
# 使用轻量级的 Alpine 镜像作为最终镜像 # 使用轻量级的 Alpine 镜像作为最终镜像
FROM alpine:latest FROM alpine:latest

View File

@ -1,9 +0,0 @@
# Intro
需要用到的 docker 配置文件。
# DEFAULT 默认配置
默认文件路径从项目的 ROOT 开始。
# ITEMS
## nginx
现在实际有用的部分就是 `run_docker.ps1`,通过获取相对路径,然后挂载到 docker 容器

View File

@ -1,26 +0,0 @@
# 使用官方的nginx基础镜像
FROM nginx
# 复制nginx配置文件到容器中
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
# 挂载宿主机目录到容器中
VOLUME ["/mnt/data", "/var/log/nginx"]
# BUG 以下配置有问题!!!
# 将宿主机的nginx日志目录映射到容器中
RUN ln -sf ./store/logs/nginx /var/log/nginx
# 将宿主机的nginx配置目录映射到容器中
RUN ln -sf /etc/nginx/nginx.conf /etc/nginx/nginx.conf
# 将宿主机的nginx html目录映射到容器中
RUN ln -sf ./public/nginx /mnt/data
# 暴露80端口
EXPOSE 80
# 启动nginx容器
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,50 +0,0 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / { # BUG 会因为下面的通配符失效。
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# INFO 配置nginx的location块以处理特定文件类型的请求
location ~ .*\.(js|css|html|htm|gif|jpg|jpeg|png|bmp|swf|ico|rar|zip|txt|flv|mid|doc|ppt|pdf|xlsx|xls|mp3|wma)$ {
root /mnt/data;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

View File

@ -1,32 +0,0 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}

View File

@ -1,36 +0,0 @@
$CurrentPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
# Define paths to check
$NginxConf = Join-Path $CurrentPath "nginx.conf"
$DefaultConf = Join-Path $CurrentPath "conf.d\default.conf"
$DataVolume = Join-Path $CurrentPath "..\..\public\nginx"
$LogVolume = Join-Path $CurrentPath "..\..\store\logs\nginx"
$pathsToCheck = @(
$NginxConf,
$DataVolume,
$LogVolume,
$DefaultConf
)
# INFO Check if each path exists
$allPathsExist = $true
foreach ($path in $pathsToCheck) {
if (-not (Test-Path -Path $path)) {
Write-Host "Path does not exist1: $path"
$allPathsExist = $false
}
& cmd /c echo Path Check: $path
}
# If all paths exist, start the Docker container
if ($allPathsExist) {
docker run -d --name nginx1 -p 80:80 `
-v "${NginxConf}:/etc/nginx/nginx.conf" `
-v "${DataVolume}:/mnt/data" `
-v "${LogVolume}:/var/log/nginx" `
-v "${DefaultConf}:/etc/nginx/conf.d/default.conf" nginx
} else {
Write-Host "One or more paths do not exist, cannot start the Docker container."
}

View File

@ -1,8 +0,0 @@
172.17.0.1 - - [29/Sep/2024:08:57:00 +0000] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"
172.17.0.1 - - [29/Sep/2024:08:57:00 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"
172.17.0.1 - - [29/Sep/2024:08:57:16 +0000] "GET /0.jpg HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"
172.17.0.1 - - [29/Sep/2024:08:57:26 +0000] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"
172.17.0.1 - - [29/Sep/2024:09:06:02 +0000] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"
172.17.0.1 - - [29/Sep/2024:09:16:42 +0000] "GET / HTTP/1.1" 200 615 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"
172.17.0.1 - - [29/Sep/2024:09:17:37 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"
172.17.0.1 - - [29/Sep/2024:09:20:18 +0000] "GET /0.jpg HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0" "-"

View File

@ -1,188 +0,0 @@
2024/09/29 08:55:51 [notice] 1#1: using the "epoll" event method
2024/09/29 08:55:51 [notice] 1#1: nginx/1.27.1
2024/09/29 08:55:51 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/09/29 08:55:51 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/09/29 08:55:51 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/09/29 08:55:51 [notice] 1#1: start worker processes
2024/09/29 08:55:51 [notice] 1#1: start worker process 22
2024/09/29 08:55:51 [notice] 1#1: start worker process 23
2024/09/29 08:55:51 [notice] 1#1: start worker process 24
2024/09/29 08:55:51 [notice] 1#1: start worker process 25
2024/09/29 08:55:51 [notice] 1#1: start worker process 26
2024/09/29 08:55:51 [notice] 1#1: start worker process 27
2024/09/29 08:55:51 [notice] 1#1: start worker process 28
2024/09/29 08:55:51 [notice] 1#1: start worker process 29
2024/09/29 08:55:51 [notice] 1#1: start worker process 30
2024/09/29 08:55:51 [notice] 1#1: start worker process 31
2024/09/29 08:55:51 [notice] 1#1: start worker process 32
2024/09/29 08:55:51 [notice] 1#1: start worker process 33
2024/09/29 08:55:51 [notice] 1#1: start worker process 34
2024/09/29 08:55:51 [notice] 1#1: start worker process 35
2024/09/29 08:55:51 [notice] 1#1: start worker process 36
2024/09/29 08:55:51 [notice] 1#1: start worker process 37
2024/09/29 08:55:51 [notice] 1#1: start worker process 38
2024/09/29 08:55:51 [notice] 1#1: start worker process 39
2024/09/29 08:55:51 [notice] 1#1: start worker process 40
2024/09/29 08:55:51 [notice] 1#1: start worker process 41
2024/09/29 08:57:00 [error] 23#23: *2 open() "/mnt/data/index.html" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2024/09/29 08:57:00 [error] 23#23: *2 open() "/mnt/data/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
2024/09/29 08:57:16 [error] 23#23: *2 open() "/mnt/data/0.jpg" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /0.jpg HTTP/1.1", host: "localhost"
2024/09/29 08:57:26 [error] 23#23: *2 open() "/mnt/data/index.html" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2024/09/29 09:05:12 [notice] 1#1: using the "epoll" event method
2024/09/29 09:05:12 [notice] 1#1: nginx/1.27.1
2024/09/29 09:05:12 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/09/29 09:05:12 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/09/29 09:05:12 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/09/29 09:05:12 [notice] 1#1: start worker processes
2024/09/29 09:05:12 [notice] 1#1: start worker process 22
2024/09/29 09:05:12 [notice] 1#1: start worker process 23
2024/09/29 09:05:12 [notice] 1#1: start worker process 24
2024/09/29 09:05:12 [notice] 1#1: start worker process 25
2024/09/29 09:05:12 [notice] 1#1: start worker process 26
2024/09/29 09:05:12 [notice] 1#1: start worker process 27
2024/09/29 09:05:12 [notice] 1#1: start worker process 28
2024/09/29 09:05:12 [notice] 1#1: start worker process 29
2024/09/29 09:05:12 [notice] 1#1: start worker process 30
2024/09/29 09:05:12 [notice] 1#1: start worker process 31
2024/09/29 09:05:12 [notice] 1#1: start worker process 32
2024/09/29 09:05:12 [notice] 1#1: start worker process 33
2024/09/29 09:05:12 [notice] 1#1: start worker process 34
2024/09/29 09:05:12 [notice] 1#1: start worker process 35
2024/09/29 09:05:12 [notice] 1#1: start worker process 36
2024/09/29 09:05:12 [notice] 1#1: start worker process 37
2024/09/29 09:05:12 [notice] 1#1: start worker process 38
2024/09/29 09:05:12 [notice] 1#1: start worker process 39
2024/09/29 09:05:12 [notice] 1#1: start worker process 40
2024/09/29 09:05:12 [notice] 1#1: start worker process 41
2024/09/29 09:06:02 [error] 22#22: *1 open() "/mnt/data/index.html" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2024/09/29 09:13:35 [notice] 1#1: using the "epoll" event method
2024/09/29 09:13:35 [notice] 1#1: nginx/1.27.1
2024/09/29 09:13:35 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/09/29 09:13:35 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/09/29 09:13:35 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/09/29 09:13:35 [notice] 1#1: start worker processes
2024/09/29 09:13:35 [notice] 1#1: start worker process 22
2024/09/29 09:13:35 [notice] 1#1: start worker process 23
2024/09/29 09:13:35 [notice] 1#1: start worker process 24
2024/09/29 09:13:35 [notice] 1#1: start worker process 25
2024/09/29 09:13:35 [notice] 1#1: start worker process 26
2024/09/29 09:13:35 [notice] 1#1: start worker process 27
2024/09/29 09:13:35 [notice] 1#1: start worker process 28
2024/09/29 09:13:35 [notice] 1#1: start worker process 29
2024/09/29 09:13:35 [notice] 1#1: start worker process 30
2024/09/29 09:13:35 [notice] 1#1: start worker process 31
2024/09/29 09:13:35 [notice] 1#1: start worker process 32
2024/09/29 09:13:35 [notice] 1#1: start worker process 33
2024/09/29 09:13:35 [notice] 1#1: start worker process 34
2024/09/29 09:13:35 [notice] 1#1: start worker process 35
2024/09/29 09:13:35 [notice] 1#1: start worker process 36
2024/09/29 09:13:35 [notice] 1#1: start worker process 37
2024/09/29 09:13:35 [notice] 1#1: start worker process 38
2024/09/29 09:13:35 [notice] 1#1: start worker process 39
2024/09/29 09:13:35 [notice] 1#1: start worker process 40
2024/09/29 09:13:35 [notice] 1#1: start worker process 41
2024/09/29 09:15:33 [notice] 1#1: using the "epoll" event method
2024/09/29 09:15:33 [notice] 1#1: nginx/1.27.1
2024/09/29 09:15:33 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/09/29 09:15:33 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/09/29 09:15:33 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/09/29 09:15:33 [notice] 1#1: start worker processes
2024/09/29 09:15:33 [notice] 1#1: start worker process 29
2024/09/29 09:15:33 [notice] 1#1: start worker process 30
2024/09/29 09:15:33 [notice] 1#1: start worker process 31
2024/09/29 09:15:33 [notice] 1#1: start worker process 32
2024/09/29 09:15:33 [notice] 1#1: start worker process 33
2024/09/29 09:15:33 [notice] 1#1: start worker process 34
2024/09/29 09:15:33 [notice] 1#1: start worker process 35
2024/09/29 09:15:33 [notice] 1#1: start worker process 36
2024/09/29 09:15:33 [notice] 1#1: start worker process 37
2024/09/29 09:15:33 [notice] 1#1: start worker process 38
2024/09/29 09:15:33 [notice] 1#1: start worker process 39
2024/09/29 09:15:33 [notice] 1#1: start worker process 40
2024/09/29 09:15:33 [notice] 1#1: start worker process 41
2024/09/29 09:15:33 [notice] 1#1: start worker process 42
2024/09/29 09:15:33 [notice] 1#1: start worker process 43
2024/09/29 09:15:33 [notice] 1#1: start worker process 44
2024/09/29 09:15:33 [notice] 1#1: start worker process 45
2024/09/29 09:15:33 [notice] 1#1: start worker process 46
2024/09/29 09:15:33 [notice] 1#1: start worker process 47
2024/09/29 09:15:33 [notice] 1#1: start worker process 48
2024/09/29 09:17:10 [notice] 1#1: using the "epoll" event method
2024/09/29 09:17:10 [notice] 1#1: nginx/1.27.1
2024/09/29 09:17:10 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/09/29 09:17:10 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/09/29 09:17:10 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/09/29 09:17:10 [notice] 1#1: start worker processes
2024/09/29 09:17:10 [notice] 1#1: start worker process 22
2024/09/29 09:17:10 [notice] 1#1: start worker process 23
2024/09/29 09:17:10 [notice] 1#1: start worker process 24
2024/09/29 09:17:10 [notice] 1#1: start worker process 25
2024/09/29 09:17:10 [notice] 1#1: start worker process 26
2024/09/29 09:17:10 [notice] 1#1: start worker process 27
2024/09/29 09:17:10 [notice] 1#1: start worker process 28
2024/09/29 09:17:10 [notice] 1#1: start worker process 29
2024/09/29 09:17:10 [notice] 1#1: start worker process 30
2024/09/29 09:17:10 [notice] 1#1: start worker process 31
2024/09/29 09:17:10 [notice] 1#1: start worker process 32
2024/09/29 09:17:10 [notice] 1#1: start worker process 33
2024/09/29 09:17:10 [notice] 1#1: start worker process 34
2024/09/29 09:17:10 [notice] 1#1: start worker process 35
2024/09/29 09:17:10 [notice] 1#1: start worker process 36
2024/09/29 09:17:10 [notice] 1#1: start worker process 37
2024/09/29 09:17:10 [notice] 1#1: start worker process 38
2024/09/29 09:17:10 [notice] 1#1: start worker process 39
2024/09/29 09:17:10 [notice] 1#1: start worker process 40
2024/09/29 09:17:10 [notice] 1#1: start worker process 41
2024/09/29 09:20:04 [notice] 1#1: using the "epoll" event method
2024/09/29 09:20:04 [notice] 1#1: nginx/1.27.1
2024/09/29 09:20:04 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/09/29 09:20:04 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/09/29 09:20:04 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/09/29 09:20:04 [notice] 1#1: start worker processes
2024/09/29 09:20:04 [notice] 1#1: start worker process 22
2024/09/29 09:20:04 [notice] 1#1: start worker process 23
2024/09/29 09:20:04 [notice] 1#1: start worker process 24
2024/09/29 09:20:04 [notice] 1#1: start worker process 25
2024/09/29 09:20:04 [notice] 1#1: start worker process 26
2024/09/29 09:20:04 [notice] 1#1: start worker process 27
2024/09/29 09:20:04 [notice] 1#1: start worker process 28
2024/09/29 09:20:04 [notice] 1#1: start worker process 29
2024/09/29 09:20:04 [notice] 1#1: start worker process 30
2024/09/29 09:20:04 [notice] 1#1: start worker process 31
2024/09/29 09:20:04 [notice] 1#1: start worker process 32
2024/09/29 09:20:04 [notice] 1#1: start worker process 33
2024/09/29 09:20:04 [notice] 1#1: start worker process 34
2024/09/29 09:20:04 [notice] 1#1: start worker process 35
2024/09/29 09:20:04 [notice] 1#1: start worker process 36
2024/09/29 09:20:04 [notice] 1#1: start worker process 37
2024/09/29 09:20:04 [notice] 1#1: start worker process 38
2024/09/29 09:20:04 [notice] 1#1: start worker process 39
2024/09/29 09:20:04 [notice] 1#1: start worker process 40
2024/09/29 09:20:04 [notice] 1#1: start worker process 41
2024/09/29 09:20:18 [error] 23#23: *1 open() "/mnt/data/0.jpg" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /0.jpg HTTP/1.1", host: "localhost"
2024/09/29 09:23:37 [notice] 1#1: using the "epoll" event method
2024/09/29 09:23:37 [notice] 1#1: nginx/1.27.1
2024/09/29 09:23:37 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/09/29 09:23:37 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2
2024/09/29 09:23:37 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/09/29 09:23:37 [notice] 1#1: start worker processes
2024/09/29 09:23:37 [notice] 1#1: start worker process 22
2024/09/29 09:23:37 [notice] 1#1: start worker process 23
2024/09/29 09:23:37 [notice] 1#1: start worker process 24
2024/09/29 09:23:37 [notice] 1#1: start worker process 25
2024/09/29 09:23:37 [notice] 1#1: start worker process 26
2024/09/29 09:23:37 [notice] 1#1: start worker process 27
2024/09/29 09:23:37 [notice] 1#1: start worker process 28
2024/09/29 09:23:37 [notice] 1#1: start worker process 29
2024/09/29 09:23:37 [notice] 1#1: start worker process 30
2024/09/29 09:23:37 [notice] 1#1: start worker process 31
2024/09/29 09:23:37 [notice] 1#1: start worker process 32
2024/09/29 09:23:37 [notice] 1#1: start worker process 33
2024/09/29 09:23:37 [notice] 1#1: start worker process 34
2024/09/29 09:23:37 [notice] 1#1: start worker process 35
2024/09/29 09:23:37 [notice] 1#1: start worker process 36
2024/09/29 09:23:37 [notice] 1#1: start worker process 37
2024/09/29 09:23:37 [notice] 1#1: start worker process 38
2024/09/29 09:23:37 [notice] 1#1: start worker process 39
2024/09/29 09:23:37 [notice] 1#1: start worker process 40
2024/09/29 09:23:37 [notice] 1#1: start worker process 41