Browse Source

build: docker working environment

master
dnomd343 2 years ago
parent
commit
2b0c368472
  1. 4
      Dockerfile
  2. 4
      conf/docker/init.sh
  3. 33
      conf/nginx/docker.conf
  4. 51
      conf/nginx/kms.conf
  5. 13
      conf/vlmcsd.service
  6. 2
      main.php
  7. 4
      nginx/kms.conf
  8. 0
      nginx/nginx.conf
  9. 3
      src/Route.php

4
Dockerfile

@ -24,4 +24,8 @@ FROM alpine:3.16
RUN apk add --no-cache nginx php8 php8-fpm php8-iconv php8-pcntl
COPY --from=iconv /iconv/ /usr/
COPY --from=vlmcsd /tmp/vlmcs* /usr/bin/
COPY . /kms-server/
RUN mv /kms-server/nginx/*.conf /etc/nginx/
EXPOSE 1688/tcp 1689/tcp
WORKDIR /kms-server/
CMD ["php", "main.php"]

4
conf/docker/init.sh

@ -1,4 +0,0 @@
/usr/sbin/php-fpm7
/usr/sbin/nginx
echo "KMS-Server initialization completed."
/usr/bin/vlmcsd -De

33
conf/nginx/docker.conf

@ -1,33 +0,0 @@
server {
listen 80;
listen [::]:80;
server_name kms.343.re; # 改为自己的域名
location / {
if ($http_user_agent !~* (curl|wget)) {
return 301 https://$server_name$request_uri;
}
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:1689;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name kms.343.re; # 改为自己的域名
ssl_certificate /etc/ssl/certs/343.re/fullchain.pem; # 改为自己的证书
ssl_certificate_key /etc/ssl/certs/343.re/privkey.pem;
gzip on;
gzip_buffers 32 4K;
gzip_comp_level 6;
gzip_min_length 100;
gzip_types application/javascript text/css text/xml;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
location / {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:1689;
}
}

51
conf/nginx/kms.conf

@ -1,51 +0,0 @@
server {
listen 80;
listen [::]:80;
server_name kms.343.re; # 改为自己的域名
location / {
if ($http_user_agent !~* (curl|wget)) {
return 301 https://$server_name$request_uri;
}
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:1689;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name kms.343.re; # 改为自己的域名
ssl_certificate /etc/ssl/certs/343.re/fullchain.pem; # 改为自己的证书
ssl_certificate_key /etc/ssl/certs/343.re/privkey.pem;
gzip on;
gzip_buffers 32 4K;
gzip_comp_level 6;
gzip_min_length 100;
gzip_types application/javascript text/css text/xml;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
location / {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:1689;
}
}
server {
listen 1689;
root /var/www/kms-server;
location / {
set $query_param $query_string;
if ($http_user_agent ~* (curl|wget)) {
set $query_param $query_param&cli=true;
}
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param QUERY_STRING $query_param;
fastcgi_param SCRIPT_FILENAME /var/www/kms-server/backend/route.php;
}
location /assets {}
}

13
conf/vlmcsd.service

@ -1,13 +0,0 @@
[Unit]
Description=KMS Server By vlmcsd
After=network.target
[Service]
Type=forking
PIDFile=/var/run/vlmcsd.pid
ExecStart=/usr/bin/vlmcsd -p /var/run/vlmcsd.pid
ExecStop=/bin/kill -HUP $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

2
main.php

@ -24,9 +24,9 @@ $vlmcsd = array(
'pidFile' => '/run/vlmcsd.pid',
);
logging::info('Loading kms-server (' . $version . ')');
declare(ticks = 1);
pcntl_signal(SIGCHLD, 'subExit'); // receive SIGCHLD signal
logging::info('Loading kms-server (' . $version . ')');
new Process($nginx['command']);
logging::info('Start nginx server...OK');

4
conf/docker/kms.conf → nginx/kms.conf

@ -1,6 +1,6 @@
server {
listen 1689;
root /var/www/kms-server;
root /kms-server;
location / {
set $query_param $query_string;
@ -10,7 +10,7 @@ server {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param QUERY_STRING $query_param;
fastcgi_param SCRIPT_FILENAME /var/www/kms-server/backend/route.php;
fastcgi_param SCRIPT_FILENAME /kms-server/src/Route.php;
}
location /assets {}

0
conf/docker/nginx.conf → nginx/nginx.conf

3
src/Route.php

@ -0,0 +1,3 @@
<?php
echo 'ok' . PHP_EOL;
Loading…
Cancel
Save