-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1990 from xiagw/fix-docker
fix docker
- Loading branch information
Showing
7 changed files
with
78 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.dockerignore | ||
.github | ||
.gitignore | ||
Dockerfile* | ||
|
||
.git/ | ||
Application/Runtime/ | ||
server/Application/Runtime/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,14 @@ | ||
FROM webdevops/php-nginx:7.4-alpine | ||
|
||
COPY ./ /var/www/html/ | ||
RUN mkdir -p /showdoc_data/html | ||
RUN cp -R /var/www/html/ /showdoc_data/ | ||
RUN rm -rf /app && ln -s /var/www/html /app | ||
RUN echo "<?php echo file_get_contents('index.html'); ?>" > /var/www/html/web/index.php | ||
## docker build --build-arg=IN_CHINA=true . | ||
ARG IN_CHINA=false | ||
|
||
RUN echo "upload_max_filesize=5000M;" >> /opt/docker/etc/php/php.ini | ||
RUN echo "post_max_size=5000M;" >> /opt/docker/etc/php/php.ini | ||
RUN echo "client_max_body_size 5000m;" > /opt/docker/etc/nginx/vhost.common.d/10-general.conf | ||
# 环境变量 | ||
ENV SHOWDOC_DOCKER_VERSION 2.4 | ||
|
||
RUN apk update | ||
RUN apk add --update nodejs npm | ||
RUN mv /showdoc_data/html/mock/ /showdoc_data/mock | ||
RUN (cd /showdoc_data/mock/ && npm install ) | ||
WORKDIR /showdoc_data/html | ||
COPY . . | ||
|
||
# 写环境变量 | ||
ENV SHOWDOC_DOCKER_VERSION 2.4 | ||
RUN bash docker.build.sh | ||
|
||
CMD if [ ! -f "/var/www/html/index.php" ]; then \cp -fr /showdoc_data/html/ /var/www/ ;fi \ | ||
;chmod 777 -R /var/www/ \ | ||
;(sleep 3 && cd /showdoc_data/html/server && php index.php /api/update/dockerUpdateCode && chmod 777 -R /var/www/ ) \ | ||
;(sleep 30 && cd /showdoc_data/mock/ && npm run start) \ | ||
& supervisord | ||
CMD ["bash", "docker.run.sh"] |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -xe | ||
|
||
rm -rf /app | ||
ln -s /var/www/html /app | ||
( | ||
echo "upload_max_filesize=5120M;" | ||
echo "post_max_size=5120M;" | ||
) >>/opt/docker/etc/php/php.ini | ||
echo "client_max_body_size 5120m;" >/opt/docker/etc/nginx/vhost.common.d/10-general.conf | ||
## fix nginx warning | ||
sed -i -e '1d' /opt/docker/etc/nginx/vhost.ssl.conf | ||
sed -i -e '/443\ default_server/s//443\ default_server\ ssl/' /opt/docker/etc/nginx/vhost.conf | ||
|
||
if [ "$IN_CHINA" = true ] && [ -f /etc/apk/repositories ]; then | ||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories | ||
fi | ||
apk update | ||
apk add --update --no-cache nodejs npm | ||
|
||
mv /showdoc_data/html/mock /showdoc_data/ | ||
cd /showdoc_data/mock || exit 1 | ||
if [ "$IN_CHINA" = true ]; then | ||
npm config set registry https://registry.npmmirror.com/ | ||
fi | ||
## fix old warn | ||
rm -f package-lock.json | ||
npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [ ! -f "/var/www/html/index.php" ]; then | ||
\cp -fr /showdoc_data/html/* /var/www/html/ | ||
fi | ||
|
||
## backup sqlite file every day | ||
db_file=/var/www/html/Sqlite/showdoc.db.php | ||
while [ -f $db_file ]; do | ||
# backup on 20:01 (UTC) every day | ||
if [[ $(date +%H%M) == 2001 ]]; then | ||
\cp $db_file ${db_file}."$(date +%F-%H-%M-%S)".php | ||
## remove old files (15 days ago) | ||
find ${db_file}.* -type f -ctime +15 -print0 | | ||
xargs -t -0 rm -f >/dev/null | ||
fi | ||
sleep 50 | ||
done & | ||
|
||
chmod 777 -R /var/www/ | ||
( | ||
sleep 3 | ||
cd /showdoc_data/html/server | ||
php index.php /api/update/dockerUpdateCode | ||
chmod 777 -R /var/www/ | ||
) | ||
( | ||
sleep 30 | ||
cd /showdoc_data/mock/ | ||
npm run start | ||
) & | ||
|
||
supervisord |