更新Docker文件

This commit is contained in:
B05BEE13.卢郴群 2020-12-18 11:08:45 +08:00
parent f4f5149e27
commit 82b45db461
2 changed files with 35 additions and 42 deletions

View File

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

View File

@ -1,9 +1,8 @@
CREATE DATABASE mybookmarks DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; -- 创建mybookmarks数据库 CREATE DATABASE IF NOT EXISTS mybookmarks DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; -- 创建mybookmarks数据库
USE mybookmarks; USE mybookmarks;
-- 用户信息表 -- 用户信息表
drop table if exists users; CREATE TABLE IF NOT EXISTS `users` (
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT, -- id `id` int(11) NOT NULL AUTO_INCREMENT, -- id
`username` varchar(255) NOT NULL, -- 用户名 `username` varchar(255) NOT NULL, -- 用户名
`password` varchar(255) NOT NULL, -- 密码 `password` varchar(255) NOT NULL, -- 密码
@ -19,8 +18,7 @@ CREATE TABLE `users` (
); );
-- 书签表 -- 书签表
drop table if exists bookmarks; CREATE TABLE IF NOT EXISTS `bookmarks` (
CREATE TABLE `bookmarks` (
`id` int(11) NOT NULL AUTO_INCREMENT, -- id `id` int(11) NOT NULL AUTO_INCREMENT, -- id
`userId` int(11) NOT NULL, -- 用户id `userId` int(11) NOT NULL, -- 用户id
`tagId` int(11) NOT NULL, -- 分类id (只允许一个书签对应一个分类) `tagId` int(11) NOT NULL, -- 分类id (只允许一个书签对应一个分类)
@ -36,8 +34,7 @@ CREATE TABLE `bookmarks` (
); );
-- 书签分类表 -- 书签分类表
drop table if exists tags; CREATE TABLE IF NOT EXISTS `tags` (
CREATE TABLE `tags` (
`id` int(11) NOT NULL AUTO_INCREMENT, -- id `id` int(11) NOT NULL AUTO_INCREMENT, -- id
`userId` int(11) NOT NULL, -- 用户id `userId` int(11) NOT NULL, -- 用户id
`name` varchar(32) NOT NULL, -- 标签 `name` varchar(32) NOT NULL, -- 标签
@ -50,8 +47,7 @@ CREATE TABLE `tags` (
); );
-- 建议留言 -- 建议留言
drop table if exists advices; CREATE TABLE IF NOT EXISTS `advices` (
CREATE TABLE `advices` (
`id` int(11) NOT NULL AUTO_INCREMENT, -- id `id` int(11) NOT NULL AUTO_INCREMENT, -- id
`userId` int(11) NOT NULL, -- 用户id `userId` int(11) NOT NULL, -- 用户id
`comment` text NOT NULL, -- 评论 `comment` text NOT NULL, -- 评论
@ -62,8 +58,7 @@ CREATE TABLE `advices` (
); );
-- 热门表 -- 热门表
drop table if exists hot_bookmarks; CREATE TABLE IF NOT EXISTS `hot_bookmarks` (
CREATE TABLE `hot_bookmarks` (
`id` int(11) NOT NULL AUTO_INCREMENT, -- id(articleId) `id` int(11) NOT NULL AUTO_INCREMENT, -- id(articleId)
`title` varchar(255) DEFAULT NULL, -- 标题(title) `title` varchar(255) DEFAULT NULL, -- 标题(title)
`url` varchar(1024) DEFAULT NULL, -- 链接(url) `url` varchar(1024) DEFAULT NULL, -- 链接(url)
@ -77,8 +72,7 @@ CREATE TABLE `hot_bookmarks` (
); );
-- 备忘录 -- 备忘录
drop table if exists notes; CREATE TABLE IF NOT EXISTS `notes` (
CREATE TABLE `notes` (
`id` int(11) NOT NULL AUTO_INCREMENT, -- id `id` int(11) NOT NULL AUTO_INCREMENT, -- id
`userId` int(11) NOT NULL, -- 用户id `userId` int(11) NOT NULL, -- 用户id
`content` text NOT NULL, -- 备忘内容 `content` text NOT NULL, -- 备忘内容