Files
SafeLine/Dockerfile

125 lines
7.1 KiB
Docker
Raw Normal View History

2023-11-22 12:05:25 +08:00
FROM golang:1.21 as go-builder
WORKDIR /work
2023-11-24 19:33:57 +08:00
ENV GOPROXY=https://goproxy.cn,direct
2023-11-29 10:40:47 +08:00
COPY backend/go.mod .
COPY backend/go.sum .
RUN go mod download
COPY backend .
2023-11-22 17:20:01 +08:00
RUN CGO_ENABLED=0 go build -a -v -ldflags="-w" -o server .
2023-11-22 12:05:25 +08:00
2023-11-04 18:17:02 +08:00
FROM node:20.5-alpine
RUN apk update
RUN apk add nginx supervisor curl
2023-11-04 18:17:02 +08:00
RUN echo -e " \n\
server { \n\
listen 80; \n\
\n\
2023-11-22 12:05:25 +08:00
location /api/ { \n\
proxy_pass http://localhost:8080; \n\
} \n\
location /docs { \n\
proxy_pass http://localhost:3000; \n\
} \n\
2023-11-04 18:17:02 +08:00
location /blazehttp { \n\
root /app/; \n\
2023-12-14 10:59:05 +08:00
try_files \$uri =404; \n\
2023-11-04 18:17:02 +08:00
} \n\
location /release { \n\
root /app/; \n\
2023-12-14 10:59:05 +08:00
try_files \$uri =404; \n\
} \n\
location /sitemap.xml { \n\
root /srv/website/public; \n\
} \n\
location /sitemap-0.xml { \n\
root /srv/website/public; \n\
} \n\
location /robots.txt { \n\
root /srv/website/public; \n\
2023-11-04 18:17:02 +08:00
} \n\
2023-12-21 16:08:10 +08:00
location /googlef97f8402f9139518.html { \n\
root /srv/website/public; \n\
} \n\
2023-12-21 16:40:10 +08:00
location /BingSiteAuth.xml { \n\
2023-12-21 16:36:31 +08:00
root /srv/website/public; \n\
} \n\
2023-11-04 18:17:02 +08:00
location / { \n\
rewrite /posts/guide_introduction /docs/ permanent; \n\
rewrite /posts/guide_install /docs/guide/install permanent; \n\
rewrite /docs/上手指南/guide_install /docs/guide/install permanent; \n\
rewrite /posts/guide_login /docs/guide/login permanent; \n\
rewrite /docs/上手指南/guide_login /docs/guide/login permanent; \n\
rewrite /posts/guide_config /docs/guide/config permanent; \n\
rewrite /docs/上手指南/guide_config /docs/guide/config permanent; \n\
rewrite /posts/guide_test /docs/guide/test permanent; \n\
rewrite /docs/上手指南/guide_test /docs/guide/test permanent; \n\
rewrite /posts/guide_upgrade /docs/guide/upgrade permanent; \n\
rewrite /docs/上手指南/guide_upgrade /docs/guide/upgrade permanent; \n\
rewrite /posts/faq_install /docs/faq/install permanent; \n\
rewrite /docs/常见问题排查/faq_install /docs/faq/install permanent; \n\
rewrite /posts/faq_login /docs/faq/login permanent; \n\
rewrite /docs/常见问题排查/faq_login /docs/faq/login permanent; \n\
rewrite /posts/faq_access /docs/guide/config permanent; \n\
rewrite /docs/常见问题排查/faq_access /docs/guide/config permanent; \n\
rewrite /posts/faq_config /docs/faq/config permanent; \n\
rewrite /docs/常见问题排查/faq_config /docs/faq/config permanent; \n\
rewrite /posts/faq_other /docs/faq/other permanent; \n\
rewrite /docs/常见问题排查/faq_other /docs/faq/other permanent; \n\
rewrite /posts/about_syntaxanalysis /docs/about/syntaxanalysis permanent; \n\
rewrite /docs/关于雷池/about_syntaxanalysis /docs/about/syntaxanalysis permanent; \n\
rewrite /posts/about_challenge /docs/about/challenge permanent; \n\
rewrite /docs/关于雷池/about_challenge /docs/about/challenge permanent; \n\
rewrite /posts/about_changelog /docs/about/changelog permanent; \n\
rewrite /docs/关于雷池/about_changelog /docs/about/changelog permanent; \n\
rewrite /posts/about_chaitin /docs/about/chaitin permanent; \n\
rewrite /docs/关于雷池/about_chaitin /docs/about/chaitin permanent; \n\
rewrite /docs/faq/access /docs/guide/config permanent; \n\
rewrite /docs/faq/config /docs/guide/config permanent; \n\
2023-11-22 12:05:25 +08:00
proxy_pass http://127.0.0.1:3001; \n\
2023-11-04 18:17:02 +08:00
} \n\
} \n\
" > /etc/nginx/http.d/default.conf
RUN sed -i 's/access_log/access_log off; #/' /etc/nginx/nginx.conf
2023-11-22 12:05:25 +08:00
# RUN nginx -t
RUN mkdir /etc/supervisor.d
RUN echo -e " \n\
[program:doc] \n\
command = npm run serve \n\
directory = /srv/documents \n\
\n\
[program:front] \n\
command = npm start \n\
directory = /srv/website \n\
\n\
[program:server] \n\
2023-11-22 17:20:01 +08:00
command = /srv/server \n\
2023-11-22 12:05:25 +08:00
" > /etc/supervisor.d/safeline.ini
COPY --from=go-builder /work/server /srv/server
2023-11-22 12:05:25 +08:00
COPY documents /srv/documents
WORKDIR /srv/documents
2023-12-28 15:36:15 +08:00
RUN npm ci; npm run build
2023-11-22 12:05:25 +08:00
# npm run serve
ENV TARGET=http://localhost:8080
COPY website /srv/website
WORKDIR /srv/website
2023-12-28 15:36:15 +08:00
RUN npm ci; npm run build
2023-11-22 12:05:25 +08:00
# npm start
2023-11-04 18:17:02 +08:00
COPY release /app/release
2023-11-22 12:05:25 +08:00
# 需要提前准备好 blazehttp 的文件5 个不通系统执行文件和 1 个 case 压缩包
COPY blazehttp/build /app/blazehttp
2023-11-04 18:17:02 +08:00
2023-11-22 12:05:25 +08:00
WORKDIR /srv
# ENV GITHUB_TOKEN=$GITHUB_TOKEN
# ENV HTTPS_PROXY=$HTTPS_PROXY
2023-11-04 18:17:02 +08:00
2023-11-22 12:05:25 +08:00
CMD supervisord; nginx -g 'daemon off;'