Skip to content

Commit

Permalink
fix dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
xiagw committed Jul 13, 2023
1 parent 8051126 commit b75de82
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.dockerignore
.github
.gitignore
Dockerfile*

.git/
Application/Runtime/
server/Application/Runtime/
Expand Down
24 changes: 4 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
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

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

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 )

# 写环境变量
ENV SHOWDOC_DOCKER_VERSION 2.4

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
COPY ./ /var/www/html/
RUN bash /var/www/html/docker.build.sh

CMD ["bash", "/var/www/html/docker.run.sh"]
21 changes: 21 additions & 0 deletions docker.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -xe
if [ ! -d /showdoc_data/html ]; then
mkdir -p /showdoc_data/html
fi
cp -R /var/www/html/ /showdoc_data/
rm -rf /app
ln -s /var/www/html /app
echo "<?php echo file_get_contents('index.html'); ?>" >/var/www/html/web/index.php
echo "upload_max_filesize=5000M;" >>/opt/docker/etc/php/php.ini
echo "post_max_size=5000M;" >>/opt/docker/etc/php/php.ini
echo "client_max_body_size 5000m;" >/opt/docker/etc/nginx/vhost.common.d/10-general.conf

apk update
apk add --update nodejs npm
mv /showdoc_data/html/mock/ /showdoc_data/mock
(
cd /showdoc_data/mock/
npm install
)
22 changes: 22 additions & 0 deletions docker.run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e

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

0 comments on commit b75de82

Please sign in to comment.