Update Dockerfile

This commit is contained in:
B05BEE13.卢郴群 2020-11-19 08:51:44 +08:00
parent 53d1bc0ea1
commit 7044dff709
1 changed files with 13 additions and 5 deletions

View File

@ -10,12 +10,20 @@ COPY production.js /app/production.js
COPY schema.sql /app/schema.sql
WORKDIR /app
RUN sed -i 's/test/root/g' /app/src/config/adapter.js \
&& sed -i 's/123456//g' /app/src/config/adapter.js \
&& npm install \
RUN USER=`sed -n '4,4p' /etc/mysql/debian.cnf | awk 'BEGIN { FS = "= " } ; { print $2 }'` \
&& sed -i "s/test/${USER}/" /app/src/config/adapter.js \
&& PASSWORD=`sed -n '5,5p' /etc/mysql/debian.cnf | awk 'BEGIN { FS = "= " } ; { print $2 }'` \
&& sed -i "s/123456/${PASSWORD}/g" /app/src/config/adapter.js \
&& npm install --production --registry=https://registry.npm.taobao.org \
&& service mysql start \
&& mysql -u root < /app/schema.sql
&& mysql -u root < /app/schema.sql \
&& touch /usr/local/bin/start.sh \
&& chmod 777 /usr/local/bin/start.sh \
&& echo "#!/bin/bash" >> /usr/local/bin/start.sh \
&& echo "service mysql restart" >> /usr/local/bin/start.sh \
&& echo "node /app/production.js" >> /usr/local/bin/start.sh
EXPOSE 3306
EXPOSE 2000
CMD ["node production.js"]
ENTRYPOINT ["start.sh"]