Skip to content

Commit 146a4ee

Browse files
author
kilingzhang
committed
fix # docker build
1 parent 3509185 commit 146a4ee

9 files changed

+111
-68
lines changed

.gitignore

100644100755
File mode changed.

Dockerfile

100644100755
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ FROM php:7.4-fpm-alpine
22

33
ADD . /var/www/html/NeteaseCloudMusicApi
44

5+
ADD docker-entrypoint.sh .
6+
ADD i.music.163.com.fpm.conf /usr/local/etc/php-fpm.d/
7+
ADD i.music.163.com.vhost.conf /etc/nginx/conf.d/
8+
ADD nginx.conf /etc/nginx/nginx.conf
9+
510
RUN set -ex \
11+
&& addgroup -g 1000 -S www && adduser -s /sbin/nologin -S -D -u 1000 -G www www \
612
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
7-
&& apk add \
8-
nginx composer \
9-
&& cd /var/www/html/NeteaseCloudMusicApi \
10-
&& composer install \
11-
&& cp service.sh /opt/ \
12-
&& cp nginx.conf /etc/nginx/nginx.conf \
13-
&& cp i.music.163.com.fpm.conf /usr/local/etc/php-fpm.d \
14-
&& cp i.music.163.com.conf /etc/nginx/conf.d \
15-
&& chmod +x /opt/service.sh
16-
13+
&& apk add nginx composer
1714

18-
ENTRYPOINT ["/opt/service.sh"]
15+
ENTRYPOINT ["./docker-entrypoint.sh"]

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@
9797

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

100-
docker stop php_container
101-
docker rm php_container
102-
103-
docker run -itd --name=php_container \
100+
docker stop netease_cloud_music_api_container;
101+
docker rm netease_cloud_music_api_container;
102+
103+
docker run -itd --name=netease_cloud_music_api_container \
104104
-p 80:80 \
105+
-v $(pwd):/var/www/html/NeteaseCloudMusicApi \
105106
kilingzhang/netease-cloud-music-api:dev
106107

107108
curl http://i.music.163.com

docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env sh
2+
3+
/usr/sbin/nginx
4+
5+
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
6+
7+
php-fpm

i.music.163.com.fpm.conf

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[i.music.163.com]
22
listen = 127.0.0.1:5337
3-
user = www-data
4-
group = www-data
3+
user = www
4+
group = www
55
listen.allowed_clients = 127.0.0.1
66
pm = dynamic
77
pm.max_children = 4

i.music.163.com.conf renamed to i.music.163.com.vhost.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ server {
55
root /var/www/html/NeteaseCloudMusicApi;
66
index index.php;
77

8+
access_log /var/log/nginx/i.music.163.com-access.log main;
9+
error_log /var/log/nginx/i.music.163.com-error.log warn;
10+
811
location / {
912
try_files $uri $uri/ /index.php?$query_string;
1013
}
@@ -15,4 +18,5 @@ server {
1518
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
1619
include fastcgi_params;
1720
}
21+
1822
}

nginx.conf

Lines changed: 76 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,93 @@
1-
user www-data;
2-
worker_processes 3;
1+
# /etc/nginx/nginx.conf
32

4-
error_log /var/log/nginx/error.log warn;
5-
pid /var/run/nginx.pid;
3+
user www;
4+
5+
# Set number of worker processes automatically based on number of CPU cores.
6+
worker_processes auto;
7+
8+
# Enables the use of JIT for regular expressions to speed-up their processing.
9+
pcre_jit on;
10+
11+
pid /var/run/nginx.pid;
12+
13+
# Configures default error logger.
14+
error_log /var/log/nginx/error.log warn;
15+
16+
# Includes files with directives to load dynamic modules.
17+
include /etc/nginx/modules/*.conf;
618

719

820
events {
9-
worker_connections 1024;
21+
# The maximum number of simultaneous connections that can be opened by
22+
# a worker process.
23+
worker_connections 1024;
1024
}
1125

12-
1326
http {
14-
include /etc/nginx/mime.types;
15-
default_type application/octet-stream;
27+
# Includes mapping of file name extensions to MIME types of responses
28+
# and defines the default type.
29+
include /etc/nginx/mime.types;
30+
default_type application/octet-stream;
31+
32+
# Name servers used to resolve names of upstream servers into addresses.
33+
# It's also needed when using tcpsocket and udpsocket in Lua modules.
34+
#resolver 208.67.222.222 208.67.220.220;
35+
36+
# Don't tell nginx version to clients.
37+
server_tokens off;
38+
39+
# Specifies the maximum accepted body size of a client request, as
40+
# indicated by the request header Content-Length. If the stated content
41+
# length is greater than this size, then the client receives the HTTP
42+
# error code 413. Set to 0 to disable.
43+
client_max_body_size 1m;
44+
45+
# Timeout for keep-alive connections. Server will close connections after
46+
# this time.
47+
keepalive_timeout 65;
48+
49+
# Sendfile copies data between one FD and other from within the kernel,
50+
# which is more efficient than read() + write().
51+
sendfile on;
52+
53+
# Don't buffer data-sends (disable Nagle algorithm).
54+
# Good for sending frequent small bursts of data in real time.
55+
tcp_nodelay on;
56+
57+
# Causes nginx to attempt to send its HTTP response head in one packet,
58+
# instead of using partial frames.
59+
#tcp_nopush on;
60+
61+
62+
# Path of the file with Diffie-Hellman parameters for EDH ciphers.
63+
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;
64+
65+
# Specifies that our cipher suits should be preferred over client ciphers.
66+
ssl_prefer_server_ciphers on;
67+
68+
# Enables a shared SSL cache with size that can hold around 8000 sessions.
69+
ssl_session_cache shared:SSL:2m;
1670

17-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
18-
'$status $body_bytes_sent "$http_referer" '
19-
'"$http_user_agent" "$http_x_forwarded_for"';
2071

21-
access_log /var/log/nginx/access.log main;
72+
# Enable gzipping of responses.
73+
#gzip on;
2274

23-
sendfile on;
24-
#tcp_nopush on;
75+
# Set the Vary HTTP header as defined in the RFC 2616.
76+
gzip_vary on;
2577

26-
keepalive_timeout 65;
78+
# Enable checking the existence of precompressed files.
79+
#gzip_static on;
2780

28-
gzip on;
2981

30-
server {
31-
listen 80;
32-
root /var/www/html;
33-
index index.php index.html;
82+
# Specifies the main log format.
83+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
84+
'$status $body_bytes_sent "$http_referer" '
85+
'"$http_user_agent" "$http_x_forwarded_for"';
3486

35-
location / {
36-
try_files $uri $uri/ /index.php?$query_string;
37-
}
87+
# Sets the path, format, and configuration for a buffered log write.
88+
access_log /var/log/nginx/access.log main;
3889

39-
location ~ \.php$ {
40-
fastcgi_pass 127.0.0.1:9000;
41-
fastcgi_index index.php;
42-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
43-
include fastcgi_params;
44-
}
45-
}
4690

47-
include conf.d/* ;
91+
# Includes virtual hosts configs.
92+
include /etc/nginx/conf.d/*.conf;
4893
}

run-docker.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#!/usr/bin/env bash
22

3-
docker build -t kilingzhang/netease-cloud-music-api:dev .
3+
docker stop netease_cloud_music_api_container
4+
docker rm netease_cloud_music_api_container
5+
docker rmi kilingzhang/netease-cloud-music-api:dev
46

5-
docker stop php_container
6-
docker rm php_container
7+
docker build -t kilingzhang/netease-cloud-music-api:dev .
78

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

12-
#docker run -itd --name=php_container \
13-
#-p 80:80 \
14-
#-v /Users/kilingzhang/Code/NeteaseCloudMusicApi-php:/var/www/html/NeteaseCloudMusicApi \
15-
#kilingzhang/netease-cloud-music-api:dev
16-
17-
docker exec -it php_container sh
14+
docker exec -it netease_cloud_music_api_container sh

service.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)