Skip to content

Commit

Permalink
fix # docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
kilingzhang committed Dec 3, 2022
1 parent 3509185 commit 146a4ee
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 68 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
19 changes: 8 additions & 11 deletions Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ FROM php:7.4-fpm-alpine

ADD . /var/www/html/NeteaseCloudMusicApi

ADD docker-entrypoint.sh .
ADD i.music.163.com.fpm.conf /usr/local/etc/php-fpm.d/
ADD i.music.163.com.vhost.conf /etc/nginx/conf.d/
ADD nginx.conf /etc/nginx/nginx.conf

RUN set -ex \
&& addgroup -g 1000 -S www && adduser -s /sbin/nologin -S -D -u 1000 -G www www \
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
&& apk add \
nginx composer \
&& cd /var/www/html/NeteaseCloudMusicApi \
&& composer install \
&& cp service.sh /opt/ \
&& cp nginx.conf /etc/nginx/nginx.conf \
&& cp i.music.163.com.fpm.conf /usr/local/etc/php-fpm.d \
&& cp i.music.163.com.conf /etc/nginx/conf.d \
&& chmod +x /opt/service.sh

&& apk add nginx composer

ENTRYPOINT ["/opt/service.sh"]
ENTRYPOINT ["./docker-entrypoint.sh"]
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@

docker build -t kilingzhang/netease-cloud-music-api:dev .

docker stop php_container
docker rm php_container
docker run -itd --name=php_container \
docker stop netease_cloud_music_api_container;
docker rm netease_cloud_music_api_container;

docker run -itd --name=netease_cloud_music_api_container \
-p 80:80 \
-v $(pwd):/var/www/html/NeteaseCloudMusicApi \
kilingzhang/netease-cloud-music-api:dev

curl http://i.music.163.com
Expand Down
7 changes: 7 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh

/usr/sbin/nginx

cd /var/www/html/NeteaseCloudMusicApi && composer install -vvv --ignore-platform-req=ext-dom --ignore-platform-req=ext-xml --ignore-platform-req=ext-xmlwriter --ignore-platform-req=ext-tokenizer

php-fpm
4 changes: 2 additions & 2 deletions i.music.163.com.fpm.conf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[i.music.163.com]
listen = 127.0.0.1:5337
user = www-data
group = www-data
user = www
group = www
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 4
Expand Down
4 changes: 4 additions & 0 deletions i.music.163.com.conf → i.music.163.com.vhost.conf
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ server {
root /var/www/html/NeteaseCloudMusicApi;
index index.php;

access_log /var/log/nginx/i.music.163.com-access.log main;
error_log /var/log/nginx/i.music.163.com-error.log warn;

location / {
try_files $uri $uri/ /index.php?$query_string;
}
Expand All @@ -15,4 +18,5 @@ server {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}
107 changes: 76 additions & 31 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,48 +1,93 @@
user www-data;
worker_processes 3;
# /etc/nginx/nginx.conf

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
user www;

# Set number of worker processes automatically based on number of CPU cores.
worker_processes auto;

# Enables the use of JIT for regular expressions to speed-up their processing.
pcre_jit on;

pid /var/run/nginx.pid;

# Configures default error logger.
error_log /var/log/nginx/error.log warn;

# Includes files with directives to load dynamic modules.
include /etc/nginx/modules/*.conf;


events {
worker_connections 1024;
# The maximum number of simultaneous connections that can be opened by
# a worker process.
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Includes mapping of file name extensions to MIME types of responses
# and defines the default type.
include /etc/nginx/mime.types;
default_type application/octet-stream;

# Name servers used to resolve names of upstream servers into addresses.
# It's also needed when using tcpsocket and udpsocket in Lua modules.
#resolver 208.67.222.222 208.67.220.220;

# Don't tell nginx version to clients.
server_tokens off;

# Specifies the maximum accepted body size of a client request, as
# indicated by the request header Content-Length. If the stated content
# length is greater than this size, then the client receives the HTTP
# error code 413. Set to 0 to disable.
client_max_body_size 1m;

# Timeout for keep-alive connections. Server will close connections after
# this time.
keepalive_timeout 65;

# Sendfile copies data between one FD and other from within the kernel,
# which is more efficient than read() + write().
sendfile on;

# Don't buffer data-sends (disable Nagle algorithm).
# Good for sending frequent small bursts of data in real time.
tcp_nodelay on;

# Causes nginx to attempt to send its HTTP response head in one packet,
# instead of using partial frames.
#tcp_nopush on;


# Path of the file with Diffie-Hellman parameters for EDH ciphers.
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;

# Specifies that our cipher suits should be preferred over client ciphers.
ssl_prefer_server_ciphers on;

# Enables a shared SSL cache with size that can hold around 8000 sessions.
ssl_session_cache shared:SSL:2m;

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;
# Enable gzipping of responses.
#gzip on;

sendfile on;
#tcp_nopush on;
# Set the Vary HTTP header as defined in the RFC 2616.
gzip_vary on;

keepalive_timeout 65;
# Enable checking the existence of precompressed files.
#gzip_static on;

gzip on;

server {
listen 80;
root /var/www/html;
index index.php index.html;
# Specifies the main log format.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Sets the path, format, and configuration for a buffered log write.
access_log /var/log/nginx/access.log main;

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

include conf.d/* ;
# Includes virtual hosts configs.
include /etc/nginx/conf.d/*.conf;
}
21 changes: 9 additions & 12 deletions run-docker.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/usr/bin/env bash

docker build -t kilingzhang/netease-cloud-music-api:dev .
docker stop netease_cloud_music_api_container
docker rm netease_cloud_music_api_container
docker rmi kilingzhang/netease-cloud-music-api:dev

docker stop php_container
docker rm php_container
docker build -t kilingzhang/netease-cloud-music-api:dev .

docker run -itd --name=php_container \
-p 80:80 \
kilingzhang/netease-cloud-music-api:dev
docker run -itd --name=netease_cloud_music_api_container \
-p 80:80 \
-v $(pwd):/var/www/html/NeteaseCloudMusicApi \
kilingzhang/netease-cloud-music-api:dev

#docker run -itd --name=php_container \
#-p 80:80 \
#-v /Users/kilingzhang/Code/NeteaseCloudMusicApi-php:/var/www/html/NeteaseCloudMusicApi \
#kilingzhang/netease-cloud-music-api:dev

docker exec -it php_container sh
docker exec -it netease_cloud_music_api_container sh
8 changes: 0 additions & 8 deletions service.sh

This file was deleted.

0 comments on commit 146a4ee

Please sign in to comment.