devin15 commited on
Commit
53ef68d
·
verified ·
1 Parent(s): 8f5a2d7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +47 -11
Dockerfile CHANGED
@@ -21,6 +21,13 @@ RUN apk update && apk upgrade && \
21
  pcre-dev \
22
  zlib-dev \
23
  openssl-dev \
 
 
 
 
 
 
 
24
  # Java 17 OpenJDK
25
  openjdk17-jdk \
26
  # 清理缓存
@@ -74,7 +81,6 @@ RUN cd /tmp && \
74
  --with-stream_realip_module \
75
  --with-stream_geoip_module=dynamic \
76
  --with-http_slice_module \
77
- --with-file-aio \
78
  --with-http_v2_module && \
79
  make && \
80
  make install && \
@@ -88,7 +94,7 @@ RUN cd /tmp && \
88
  chown -R nginx:nginx /var/cache/nginx && \
89
  chown -R nginx:nginx /var/log/nginx
90
 
91
- # 创建nginx配置文件
92
  RUN echo 'user nginx;' > /etc/nginx/nginx.conf && \
93
  echo 'worker_processes auto;' >> /etc/nginx/nginx.conf && \
94
  echo 'error_log /var/log/nginx/error.log;' >> /etc/nginx/nginx.conf && \
@@ -105,7 +111,7 @@ RUN echo 'user nginx;' > /etc/nginx/nginx.conf && \
105
  echo ' keepalive_timeout 65;' >> /etc/nginx/nginx.conf && \
106
  echo '' >> /etc/nginx/nginx.conf && \
107
  echo ' server {' >> /etc/nginx/nginx.conf && \
108
- echo ' listen 80;' >> /etc/nginx/nginx.conf && \
109
  echo ' server_name localhost;' >> /etc/nginx/nginx.conf && \
110
  echo ' location / {' >> /etc/nginx/nginx.conf && \
111
  echo ' root /usr/share/nginx/html;' >> /etc/nginx/nginx.conf && \
@@ -114,28 +120,58 @@ RUN echo 'user nginx;' > /etc/nginx/nginx.conf && \
114
  echo ' }' >> /etc/nginx/nginx.conf && \
115
  echo '}' >> /etc/nginx/nginx.conf
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  # 创建默认网页目录和文件
118
  RUN mkdir -p /usr/share/nginx/html && \
119
- echo '<h1>Welcome to nginx!</h1>' > /usr/share/nginx/html/index.html && \
120
- echo '<p>Java Version:</p>' >> /usr/share/nginx/html/index.html && \
121
- java -version 2>&1 | head -1 | sed 's/^/<p>/' | sed 's/$/<\/p>/' >> /usr/share/nginx/html/index.html
 
 
 
 
 
 
 
 
 
122
 
123
  # 验证安装
124
  RUN nginx -t && \
125
  java -version
126
 
127
- # 暴露端口
128
- # EXPOSE 80 443
129
- EXPOSE 80
130
 
131
  # 创建启动脚本
132
  RUN echo '#!/bin/sh' > /start.sh && \
133
- echo 'echo "Starting services..."' >> /start.sh && \
134
  echo 'echo "Java version:"' >> /start.sh && \
135
  echo 'java -version' >> /start.sh && \
 
136
  echo 'echo "Nginx version:"' >> /start.sh && \
137
  echo 'nginx -v' >> /start.sh && \
138
- echo 'echo "Starting nginx..."' >> /start.sh && \
 
 
 
 
139
  echo 'nginx -g "daemon off;"' >> /start.sh && \
140
  chmod +x /start.sh
141
 
 
21
  pcre-dev \
22
  zlib-dev \
23
  openssl-dev \
24
+ linux-headers \
25
+ # 添加AIO支持相关包
26
+ libaio-dev \
27
+ # nginx编译需要的额外依赖
28
+ libxslt-dev \
29
+ gd-dev \
30
+ geoip-dev \
31
  # Java 17 OpenJDK
32
  openjdk17-jdk \
33
  # 清理缓存
 
81
  --with-stream_realip_module \
82
  --with-stream_geoip_module=dynamic \
83
  --with-http_slice_module \
 
84
  --with-http_v2_module && \
85
  make && \
86
  make install && \
 
94
  chown -R nginx:nginx /var/cache/nginx && \
95
  chown -R nginx:nginx /var/log/nginx
96
 
97
+ # 创建nginx配置文件(修改端口为7860)
98
  RUN echo 'user nginx;' > /etc/nginx/nginx.conf && \
99
  echo 'worker_processes auto;' >> /etc/nginx/nginx.conf && \
100
  echo 'error_log /var/log/nginx/error.log;' >> /etc/nginx/nginx.conf && \
 
111
  echo ' keepalive_timeout 65;' >> /etc/nginx/nginx.conf && \
112
  echo '' >> /etc/nginx/nginx.conf && \
113
  echo ' server {' >> /etc/nginx/nginx.conf && \
114
+ echo ' listen 7860;' >> /etc/nginx/nginx.conf && \
115
  echo ' server_name localhost;' >> /etc/nginx/nginx.conf && \
116
  echo ' location / {' >> /etc/nginx/nginx.conf && \
117
  echo ' root /usr/share/nginx/html;' >> /etc/nginx/nginx.conf && \
 
120
  echo ' }' >> /etc/nginx/nginx.conf && \
121
  echo '}' >> /etc/nginx/nginx.conf
122
 
123
+ # 创建mime.types文件
124
+ RUN echo 'types {' > /etc/nginx/mime.types && \
125
+ echo ' text/html html htm shtml;' >> /etc/nginx/mime.types && \
126
+ echo ' text/css css;' >> /etc/nginx/mime.types && \
127
+ echo ' text/xml xml;' >> /etc/nginx/mime.types && \
128
+ echo ' image/gif gif;' >> /etc/nginx/mime.types && \
129
+ echo ' image/jpeg jpeg jpg;' >> /etc/nginx/mime.types && \
130
+ echo ' application/javascript js;' >> /etc/nginx/mime.types && \
131
+ echo ' application/atom+xml atom;' >> /etc/nginx/mime.types && \
132
+ echo ' application/rss+xml rss;' >> /etc/nginx/mime.types && \
133
+ echo ' text/plain txt;' >> /etc/nginx/mime.types && \
134
+ echo ' image/png png;' >> /etc/nginx/mime.types && \
135
+ echo ' image/x-icon ico;' >> /etc/nginx/mime.types && \
136
+ echo ' application/pdf pdf;' >> /etc/nginx/mime.types && \
137
+ echo ' application/json json;' >> /etc/nginx/mime.types && \
138
+ echo '}' >> /etc/nginx/mime.types
139
+
140
  # 创建默认网页目录和文件
141
  RUN mkdir -p /usr/share/nginx/html && \
142
+ echo '<!DOCTYPE html>' > /usr/share/nginx/html/index.html && \
143
+ echo '<html>' >> /usr/share/nginx/html/index.html && \
144
+ echo '<head><title>Welcome to nginx on port 7860!</title></head>' >> /usr/share/nginx/html/index.html && \
145
+ echo '<body>' >> /usr/share/nginx/html/index.html && \
146
+ echo '<h1>Welcome to nginx on port 7860!</h1>' >> /usr/share/nginx/html/index.html && \
147
+ echo '<p>If you see this page, the nginx web server is successfully installed and working on port 7860.</p>' >> /usr/share/nginx/html/index.html && \
148
+ echo '<p><strong>Java Environment:</strong></p>' >> /usr/share/nginx/html/index.html && \
149
+ echo '<pre>' >> /usr/share/nginx/html/index.html && \
150
+ java -version 2>&1 >> /usr/share/nginx/html/index.html && \
151
+ echo '</pre>' >> /usr/share/nginx/html/index.html && \
152
+ echo '</body>' >> /usr/share/nginx/html/index.html && \
153
+ echo '</html>' >> /usr/share/nginx/html/index.html
154
 
155
  # 验证安装
156
  RUN nginx -t && \
157
  java -version
158
 
159
+ # 暴露端口7860和443(HTTPS)
160
+ EXPOSE 7860
 
161
 
162
  # 创建启动脚本
163
  RUN echo '#!/bin/sh' > /start.sh && \
164
+ echo 'echo "=== Container Starting ==="' >> /start.sh && \
165
  echo 'echo "Java version:"' >> /start.sh && \
166
  echo 'java -version' >> /start.sh && \
167
+ echo 'echo ""' >> /start.sh && \
168
  echo 'echo "Nginx version:"' >> /start.sh && \
169
  echo 'nginx -v' >> /start.sh && \
170
+ echo 'echo ""' >> /start.sh && \
171
+ echo 'echo "Testing nginx configuration..."' >> /start.sh && \
172
+ echo 'nginx -t' >> /start.sh && \
173
+ echo 'echo ""' >> /start.sh && \
174
+ echo 'echo "Starting nginx on port 7860..."' >> /start.sh && \
175
  echo 'nginx -g "daemon off;"' >> /start.sh && \
176
  chmod +x /start.sh
177