更新Docker文件
This commit is contained in:
parent
f4f5149e27
commit
82b45db461
57
Dockerfile
57
Dockerfile
|
|
@ -1,29 +1,28 @@
|
||||||
FROM luchenqun/ubuntu-mysql-node
|
FROM luchenqun/ubuntu-mysql-node
|
||||||
LABEL maintainer="luchenqun@qq.com"
|
LABEL maintainer="luchenqun@qq.com"
|
||||||
|
|
||||||
RUN mkdir -p /app
|
RUN mkdir -p /app
|
||||||
COPY src /app/src
|
COPY src /app/src
|
||||||
COPY view /app/view
|
COPY view /app/view
|
||||||
COPY www /app/www
|
COPY www /app/www
|
||||||
COPY package.json /app/package.json
|
COPY package.json /app/package.json
|
||||||
COPY production.js /app/production.js
|
COPY production.js /app/production.js
|
||||||
COPY schema.sql /app/schema.sql
|
COPY schema.sql /app/schema.sql
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN USER=`sed -n '4,4p' /etc/mysql/debian.cnf | awk 'BEGIN { FS = "= " } ; { print $2 }'` \
|
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 \
|
&& sed -i "s/test/${USER}/" /app/src/config/adapter.js \
|
||||||
&& 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 \
|
&& touch /usr/local/bin/start.sh \
|
||||||
&& mysql -u root < /app/schema.sql \
|
&& chmod 777 /usr/local/bin/start.sh \
|
||||||
&& touch /usr/local/bin/start.sh \
|
&& echo "#!/bin/bash" >> /usr/local/bin/start.sh \
|
||||||
&& chmod 777 /usr/local/bin/start.sh \
|
&& echo "service mysql restart" >> /usr/local/bin/start.sh \
|
||||||
&& echo "#!/bin/bash" >> /usr/local/bin/start.sh \
|
&& echo "mysql -u root < /app/schema.sql" >> /usr/local/bin/start.sh \
|
||||||
&& echo "service mysql restart" >> /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
|
EXPOSE 2000
|
||||||
EXPOSE 2000
|
|
||||||
|
ENTRYPOINT ["start.sh"]
|
||||||
ENTRYPOINT ["start.sh"]
|
|
||||||
|
|
|
||||||
20
schema.sql
20
schema.sql
|
|
@ -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, -- 备忘内容
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue