U - 文档 - 更新Dockerfile文件

pull/11/head
zyupo 2019-05-21 14:01:57 +08:00
parent cd2dadd05e
commit dd7601b5e1
5 changed files with 21 additions and 19 deletions

View File

@ -1,19 +1,17 @@
FROM alpine:3.6
FROM python:3.6-alpine
RUN echo -e "http://mirrors.aliyun.com/alpine/v3.9/main\nhttp://mirrors.aliyun.com/alpine/v3.9/community" > /etc/apk/repositories
RUN apk update && apk add --no-cache nginx mariadb nodejs-npm git
RUN apk add --no-cache --virtual .build-deps openssl-dev gcc musl-dev python3-dev libffi-dev openssl-dev make
RUN git clone https://github.com/openspug/spug.git --depth=1 /spug && cd /spug && git pull
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && pip install --upgrade pip && pip install --no-cache-dir -r /spug/spug_api/requirements.txt \
&& pip install --no-cache-dir gunicorn \
&& apk del .build-deps
RUN cd /spug/spug_web/ && npm i && npm run build \
&& mv /spug/spug_web/dist /var/www/
RUN echo -e "http://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community" > /etc/apk/repositories
RUN apk update && apk add --no-cache ca-certificates python3 nginx mariadb nodejs-npm git
RUN apk add --no-cache --virtual .build-deps python3-dev gcc musl-dev libffi-dev openssl-dev make \
&& git clone https://github.com/openspug/spug.git /spug \
&& cd /spug && git pull \
&& pip3 install --no-cache-dir -r /spug/spug_api/requirements.txt \
&& pip3 install --no-cache-dir gunicorn \
&& apk del .build-deps
RUN cd /spug/spug_web/ && npm i -d --registry=https://registry.npm.taobao.org \
&& npm run build \
&& mv /var/lib/nginx/html /var/lib/nginx/html.bak && mv /spug/spug_web/dist /var/lib/nginx/html
ADD default.conf /etc/nginx/conf.d/default.conf
ADD entrypoint.sh /entrypoint.sh
ADD scripts /scripts
ENTRYPOINT ["sh", "/entrypoint.sh"]
ENTRYPOINT ["sh", "/entrypoint.sh"]

View File

@ -14,7 +14,7 @@ server {
}
location / {
root /var/lib/nginx/html;
root /var/www/dist/;
}
error_page 404 =200 /index.html;

View File

@ -26,7 +26,7 @@ fi
cd /spug/spug_api
nginx
nohup /usr/bin/mysqld_safe --datadir=/var/lib/mysql --user=root &
sleep 2
/usr/bin/python3 /scripts/init_spug.py
sleep 3
/usr/local/bin/python /scripts/init_spug.py
gunicorn --threads=32 main:app -b 0.0.0.0:3000

View File

@ -11,6 +11,8 @@ DOCKER_URL = 'unix:///var/run/docker.sock'
SQLALCHEMY_ECHO = False
EOF
echo "SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://${MYSQL_USER:-spuguser}:${MYSQL_PASSWORD:-spugpwd}@localhost/${MYSQL_DATABASE:-spug}'" >> /spug/spug_api/config.py
echo "SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://${MYSQL_USER:-spuguser}:${MYSQL_PASSWORD:-spugpwd}@localhost/${MYSQL_DATABASE:-spug}?unix_socket=/run/mysqld/mysqld.sock'" >> /spug/spug_api/config.py
echo "DOCKER_REGISTRY_SERVER = '${REGISTRY_SERVER:-hub.qbangmang.com}'" >> /spug/spug_api/config.py
echo "DOCKER_REGISTRY_AUTH = {'username': '${REGISTRY_USER}', 'password': '${REGISTRY_PASSWORD}'}" >> /spug/spug_api/config.py
cat /spug/spug_api/config.py

View File

@ -1,7 +1,9 @@
set -e
if [ ! -d /var/lib/mysql/mysql ]; then
mysql_install_db &> /dev/null
echo 'start init mysql.........'
# mysql_install_db &> /dev/null
mysql_install_db --datadir=/var/lib/mysql
mkdir -p /run/mysqld
tfile=`mktemp`
echo "USE mysql;" >> $tfile