Browse Source

feat: docker support

master
Dnomd343 3 years ago
parent
commit
e25101e03a
  1. 24
      Dockerfile
  2. 22
      conf/docker/iconv.sh
  3. 4
      conf/docker/init.sh
  4. 17
      conf/docker/kms.conf
  5. 13
      conf/docker/nginx.conf
  6. 54
      conf/docker/vlmcsd.sh

24
Dockerfile

@ -0,0 +1,24 @@
FROM alpine as iconv
COPY ./conf/docker/iconv.sh /
RUN sh /iconv.sh
FROM alpine as vlmcsd
COPY ./conf/docker/vlmcsd.sh /
RUN apk --update add --no-cache curl wget && \
sh /vlmcsd.sh
FROM alpine
LABEL maintainer="dnomd343"
COPY . /var/www/kms-server
COPY --from=iconv /tmp/iconv/ /usr/local/lib/
COPY --from=vlmcsd /tmp/vlmcsd/vlmcsd /usr/bin/vlmcsd
RUN apk --update add --no-cache nginx curl php7 php7-fpm php7-json php7-iconv php7-sqlite3 && \
rm /usr/lib/php7/modules/iconv.so && ln -s /usr/local/lib/iconv.so /usr/lib/php7/modules/ && \
mv /usr/local/lib/libiconv.so /usr/local/lib/libiconv.so.2 && \
mkdir -p /run/nginx && touch /run/nginx/nginx.pid && \
cp /var/www/kms-server/conf/docker/init.sh / && \
cp /var/www/kms-server/conf/docker/kms.conf /etc/nginx/kms.conf && \
cp -f /var/www/kms-server/conf/docker/nginx.conf /etc/nginx/nginx.conf && \
cp /var/www/kms-server/conf/docker/init.sh /
EXPOSE 1688 1689
CMD ["sh","init.sh"]

22
conf/docker/iconv.sh

@ -0,0 +1,22 @@
apk add --update wget php7 php7-dev build-base autoconf re2c libtool
mkdir -p /tmp
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz -O /tmp/libiconv.tar.gz
tar xf /tmp/libiconv.tar.gz -C /tmp
cd /tmp/libiconv-1.16/
sed -i 's/_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");/#if HAVE_RAW_DECL_GETS\n_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");\n#endif/g' srclib/stdio.in.h
./configure --prefix=/usr/local
make && make install
php_version=`php -r "phpinfo();" | grep "PHP Version" | head -1`
php_version=${php_version#*=> }
wget http://php.net/distributions/php-$php_version.tar.gz -O /tmp/php.tar.gz
tar xf /tmp/php.tar.gz -C /tmp
cd /tmp/php-$php_version/ext/iconv
phpize
./configure --with-iconv=/usr/local
make && make install
mkdir /tmp/iconv
cp /usr/local/lib/libiconv.so /tmp/iconv
cp /usr/lib/php7/modules/iconv.so /tmp/iconv

4
conf/docker/init.sh

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

17
conf/docker/kms.conf

@ -0,0 +1,17 @@
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/docker/nginx.conf

@ -0,0 +1,13 @@
user nginx;
worker_processes auto;
pcre_jit on;
include /etc/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
include /etc/nginx/kms.conf;
}

54
conf/docker/vlmcsd.sh

@ -0,0 +1,54 @@
get_github_latest_version() {
VERSION=$(curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/');
}
get_architecture() {
case "$(uname -m)" in
'i386' | 'i686')
MACHINE='i386'
;;
'amd64' | 'x86_64')
MACHINE='amd64'
;;
'armv7' | 'armv7l')
MACHINE='arm'
;;
'armv8' | 'aarch64')
MACHINE='arm64'
;;
*)
echo "The architecture is not supported."
exit 1
;;
esac
}
VLMCSD_DIR="/tmp/vlmcsd"
PKG_DIR="$VLMCSD_DIR/pkg"
mkdir -p $PKG_DIR
get_architecture
case "$MACHINE" in
'i386')
VLMCSD_PATH="binaries/Linux/intel/static/vlmcsd-x86-musl-static"
;;
'amd64')
VLMCSD_PATH="binaries/Linux/intel/static/vlmcsd-x64-musl-static"
;;
'arm')
VLMCSD_PATH=""
;;
'arm64')
VLMCSD_PATH=""
;;
*)
exit 1
;;
esac
get_github_latest_version "Wind4/vlmcsd"
wget -P $PKG_DIR "https://github.com/Wind4/vlmcsd/releases/download/$VERSION/binaries.tar.gz"
tar xf $PKG_DIR/binaries.tar.gz -C $PKG_DIR
mv $PKG_DIR/$VLMCSD_PATH $VLMCSD_DIR/vlmcsd
rm -rf $PKG_DIR
Loading…
Cancel
Save