-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
209 lines (164 loc) · 6.18 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
FROM node:20-bullseye
ENV FLYINGFISH_NGINX_MODULE_MODE_DYN="0"
ARG NPM_REGISTRY="https://registry.npmjs.org/"
ARG NGINX_VERSION="1.26.2"
ARG HEADERS_MORE_VERSION="v0.38"
ARG NJS_BRANCH="0.8.9"
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y dublin-traceroute
RUN apt-get install -y iputils-ping
RUN apt-get install -y openssl
RUN apt-get install -y curl gnupg2 ca-certificates lsb-release debian-archive-keyring
RUN apt install -y python3-pip python3-dev
RUN apt install -y git
RUN apt-get remove -y nginx nginx-common
RUN cd ~ && wget https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && tar -zxvf nginx-$NGINX_VERSION.tar.gz
RUN apt update -y
RUN apt-get upgrade -y
RUN apt-get install -y build-essential
RUN apt-get install -y libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev
RUN apt-get install -y mercurial
RUN cd ~ && \
git clone --depth 1 --branch $NJS_BRANCH https://github.com/nginx/njs.git && \
cd ~/njs && \
./configure && \
make
RUN cd ~ && \
git clone --depth 1 -b $HEADERS_MORE_VERSION --single-branch https://github.com/openresty/headers-more-nginx-module.git \
&& cd ~/headers-more-nginx-module \
&& git submodule update --init
RUN cd ~/nginx-$NGINX_VERSION && \
./configure \
--sbin-path=/usr/bin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-pcre \
--pid-path=/var/run/nginx.pid \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-http_v3_module \
--with-http_secure_link_module \
--add-module=../njs/nginx \
--add-module=../headers-more-nginx-module/ \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt="-I../quictls/build/include" \
--with-ld-opt="-L../quictls/build/lib" \
--modules-path=/usr/lib/nginx/modules/ &&\
make && \
make install
RUN pip3 install pip --upgrade
RUN pip3 install certbot-nginx
RUN mkdir /etc/letsencrypt
# Init App dirs --------------------------------------------------------------------------------------------------------
RUN mkdir -p /opt/flyingfish/schemas
RUN mkdir -p /opt/flyingfish/core
RUN mkdir -p /opt/flyingfish/backend
RUN mkdir -p /opt/flyingfish/frontend
RUN mkdir -p /opt/flyingfish/nginx
RUN mkdir -p /opt/flyingfish/nginx/html
RUN mkdir -p /opt/flyingfish/plugins
RUN mkdir -p /opt/flyingfish
RUN mkdir -p /var/log/flyingfish
RUN mkdir -p /var/lib/flyingfish
# Copy Schemas ---------------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish/schemas
COPY ./schemas/ ./
RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true
# Copy Core ------------------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish/core
COPY ./core/ ./
RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true
# Copy Plugins ---------------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish/plugins
COPY ./plugins/package.json ./
RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true
WORKDIR /opt/flyingfish/plugins/letsencrypt
COPY ./plugins/letsencrypt/ ./
RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true
# Copy/ Backend --------------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish/backend
COPY backend ./
RUN rm -R node_modules | true
RUN rm -R dist | true
RUN rm package-lock.json | true
# Copy/Install Frontend ------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish/frontend
COPY frontend ./
RUN rm -R ./node_modules | true
RUN rm -R ./dist | true
RUN rm ./package-lock.json | true
# Install All ----------------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish
COPY ./package.json ./
RUN npm install --registry=$NPM_REGISTRY --maxsockets 1 --loglevel verbose
WORKDIR /opt/flyingfish/schemas
RUN npm run build
WORKDIR /opt/flyingfish/core
RUN npm run build
WORKDIR /opt/flyingfish/plugins/letsencrypt
RUN npm run build
WORKDIR /opt/flyingfish/backend
RUN npm run build
WORKDIR /opt/flyingfish/frontend
RUN npm install --registry=$NPM_REGISTRY --force
RUN npm run gulp-copy-data
RUN npm run gulp-build-webpack
# Copy/Install nginx ---------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish/nginx
COPY nginx ./
RUN rm -R ./node_modules | true
RUN rm -R ./dist | true
RUN rm -R ./logs | true
RUN rm -R ./body | true
RUN rm -R ./sample | true
RUN rm -R ./servers | true
RUN rm ./package-lock.json | true
RUN rm ./nginx.pid | true
RUN rm ./dhparam.pem | true
RUN rm nginx.conf | true
RUN mkdir /opt/flyingfish/nginx/servers
RUN mkdir /opt/flyingfish/nginx/servers/proxy_temp
RUN chmod 700 /opt/flyingfish/nginx/servers/proxy_temp
RUN mkdir /opt/flyingfish/nginx/logs
RUN chmod 755 /opt/flyingfish/nginx/logs
RUN npm install
# add supervisor -------------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish
RUN npm install supervisor -g
# defaults ports -------------------------------------------------------------------------------------------------------
EXPOSE 80
EXPOSE 443
EXPOSE 3000
# start main app -------------------------------------------------------------------------------------------------------
WORKDIR /opt/flyingfish
CMD [ "node", "backend/dist/main.js", "--envargs=1"]