update docker images.
This commit is contained in:
parent
6f55bce07a
commit
8c0128c4e7
@ -2,7 +2,8 @@ FROM ubuntu:22.04
|
|||||||
LABEL maintainer="amass <168062547@qq.com>"
|
LABEL maintainer="amass <168062547@qq.com>"
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
ENV CODE_VERSION=4.93.1
|
ENV CODE_VERSION=4.95.1
|
||||||
|
ENV WT_VERSION=4.11.1
|
||||||
|
|
||||||
RUN sed -i "s@http://.*archive.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list \
|
RUN sed -i "s@http://.*archive.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list \
|
||||||
&& sed -i "s@http://.*security.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list \
|
&& sed -i "s@http://.*security.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list \
|
||||||
@ -92,13 +93,13 @@ RUN cd /root \
|
|||||||
&& rm -fr /root/nng-1.9.0*
|
&& rm -fr /root/nng-1.9.0*
|
||||||
|
|
||||||
RUN cd /root \
|
RUN cd /root \
|
||||||
&& wget https://github.com/emweb/wt/archive/4.11.0.tar.gz -O wt-4.11.0.tar.gz \
|
&& wget https://github.com/emweb/wt/archive/${WT_VERSION}.tar.gz -O wt-${WT_VERSION}.tar.gz \
|
||||||
&& tar xvf wt-4.11.0.tar.gz \
|
&& tar xvf wt-${WT_VERSION}.tar.gz \
|
||||||
&& cd /root/wt-4.11.0 \
|
&& cd /root/wt-${WT_VERSION} \
|
||||||
&& cmake -G Ninja -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/Libraries/wt-4.11.0 -DENABLE_QT4=OFF -DENABLE_QT5=OFF -DENABLE_QT6=OFF -DBOOST_ROOT=/opt/Libraries/boost_1_86_0 \
|
&& cmake -G Ninja -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/Libraries/wt-${WT_VERSION} -DENABLE_QT4=OFF -DENABLE_QT5=OFF -DENABLE_QT6=OFF -DBOOST_ROOT=/opt/Libraries/boost_1_86_0 \
|
||||||
&& cmake --build build --target all \
|
&& cmake --build build --target all \
|
||||||
&& cmake --install build \
|
&& cmake --install build \
|
||||||
&& rm -fr /root/wt-4.11.0*
|
&& rm -fr /root/wt-${WT_VERSION}*
|
||||||
|
|
||||||
RUN cd /root \
|
RUN cd /root \
|
||||||
&& git clone --depth=1 --recursive https://github.com/ZLMediaKit/ZLMediaKit.git \
|
&& git clone --depth=1 --recursive https://github.com/ZLMediaKit/ZLMediaKit.git \
|
||||||
|
@ -2,7 +2,8 @@ FROM ubuntu:24.04
|
|||||||
LABEL maintainer="amass <168062547@qq.com>"
|
LABEL maintainer="amass <168062547@qq.com>"
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
ENV CODE_VERSION=4.93.1
|
ENV CODE_VERSION=4.95.1
|
||||||
|
ENV WT_VERSION=4.11.1
|
||||||
|
|
||||||
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources \
|
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources \
|
||||||
&& apt update \
|
&& apt update \
|
||||||
@ -92,13 +93,13 @@ RUN cd /root \
|
|||||||
&& rm -fr /root/nng-1.9.0*
|
&& rm -fr /root/nng-1.9.0*
|
||||||
|
|
||||||
RUN cd /root \
|
RUN cd /root \
|
||||||
&& wget https://github.com/emweb/wt/archive/4.11.0.tar.gz -O wt-4.11.0.tar.gz \
|
&& wget https://github.com/emweb/wt/archive/${WT_VERSION}.tar.gz -O wt-${WT_VERSION}.tar.gz \
|
||||||
&& tar xvf wt-4.11.0.tar.gz \
|
&& tar xvf wt-${WT_VERSION}.tar.gz \
|
||||||
&& cd /root/wt-4.11.0 \
|
&& cd /root/wt-${WT_VERSION} \
|
||||||
&& cmake -G Ninja -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/Libraries/wt-4.11.0 -DENABLE_QT4=OFF -DENABLE_QT5=OFF -DENABLE_QT6=OFF -DBOOST_ROOT=/opt/Libraries/boost_1_86_0 \
|
&& cmake -G Ninja -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/Libraries/wt-${WT_VERSION} -DENABLE_QT4=OFF -DENABLE_QT5=OFF -DENABLE_QT6=OFF -DBOOST_ROOT=/opt/Libraries/boost_1_86_0 \
|
||||||
&& cmake --build build --target all \
|
&& cmake --build build --target all \
|
||||||
&& cmake --install build \
|
&& cmake --install build \
|
||||||
&& rm -fr /root/wt-4.11.0*
|
&& rm -fr /root/wt-${WT_VERSION}*
|
||||||
|
|
||||||
RUN cd /root \
|
RUN cd /root \
|
||||||
&& git clone --depth=1 --recursive https://github.com/ZLMediaKit/ZLMediaKit.git \
|
&& git clone --depth=1 --recursive https://github.com/ZLMediaKit/ZLMediaKit.git \
|
||||||
|
@ -12,8 +12,7 @@ static std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironmen
|
|||||||
return std::make_unique<Hello>(env, false);
|
return std::make_unique<Hello>(env, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Wt::WApplication> createBlogApplication(const Wt::WEnvironment &env,
|
std::unique_ptr<Wt::WApplication> createBlogApplication(const Wt::WEnvironment &env, Wt::Dbo::SqlConnectionPool *blogDb) {
|
||||||
Wt::Dbo::SqlConnectionPool *blogDb) {
|
|
||||||
return std::make_unique<BlogApplication>(env, *blogDb);
|
return std::make_unique<BlogApplication>(env, *blogDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,9 +31,9 @@ WebApplication::WebApplication() {
|
|||||||
m_server->addEntryPoint(Wt::EntryPointType::Application, createApplication, "/hello");
|
m_server->addEntryPoint(Wt::EntryPointType::Application, createApplication, "/hello");
|
||||||
|
|
||||||
BlogSession::configureAuth();
|
BlogSession::configureAuth();
|
||||||
auto blogDb = BlogSession::createConnectionPool(m_server->appRoot() + "database.sqlite");
|
m_blogSqlConnectionPool = BlogSession::createConnectionPool(m_server->appRoot() + "database.sqlite");
|
||||||
m_server->addEntryPoint(Wt::EntryPointType::Application,
|
m_server->addEntryPoint(Wt::EntryPointType::Application, std::bind(&createBlogApplication, std::placeholders::_1, m_blogSqlConnectionPool.get()),
|
||||||
std::bind(&createBlogApplication, std::placeholders::_1, blogDb.get()), "/blog");
|
"/blog");
|
||||||
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet, createWidgetSet, "/gui/hello.js");
|
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet, createWidgetSet, "/gui/hello.js");
|
||||||
Session::configureAuth();
|
Session::configureAuth();
|
||||||
m_server->addResource(std::make_shared<JsonResource>(), "/json");
|
m_server->addResource(std::make_shared<JsonResource>(), "/json");
|
||||||
|
@ -6,7 +6,11 @@
|
|||||||
|
|
||||||
namespace Wt {
|
namespace Wt {
|
||||||
class WServer;
|
class WServer;
|
||||||
};
|
|
||||||
|
namespace Dbo {
|
||||||
|
class SqlConnectionPool;
|
||||||
|
}
|
||||||
|
}; // namespace Wt
|
||||||
|
|
||||||
class WebApplication {
|
class WebApplication {
|
||||||
public:
|
public:
|
||||||
@ -19,6 +23,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<Wt::WServer> m_server;
|
std::unique_ptr<Wt::WServer> m_server;
|
||||||
std::thread m_thread;
|
std::thread m_thread;
|
||||||
|
std::unique_ptr<Wt::Dbo::SqlConnectionPool> m_blogSqlConnectionPool;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __WEBAPPLICATION_H__
|
#endif // __WEBAPPLICATION_H__
|
@ -1,4 +1,9 @@
|
|||||||
#include "BlogSession.h"
|
#include "BlogSession.h"
|
||||||
|
#include "BoostLog.h"
|
||||||
|
#include "Post.h"
|
||||||
|
#include "Token.h"
|
||||||
|
#include "User.h"
|
||||||
|
#include "asciidoc.h"
|
||||||
#include <Wt/Auth/AuthService.h>
|
#include <Wt/Auth/AuthService.h>
|
||||||
#include <Wt/Auth/GoogleService.h>
|
#include <Wt/Auth/GoogleService.h>
|
||||||
#include <Wt/Auth/HashFunction.h>
|
#include <Wt/Auth/HashFunction.h>
|
||||||
@ -7,6 +12,9 @@
|
|||||||
#include <Wt/Auth/PasswordVerifier.h>
|
#include <Wt/Auth/PasswordVerifier.h>
|
||||||
#include <Wt/Dbo/FixedSqlConnectionPool.h>
|
#include <Wt/Dbo/FixedSqlConnectionPool.h>
|
||||||
|
|
||||||
|
const std::string ADMIN_USERNAME = "admin";
|
||||||
|
const std::string ADMIN_PASSWORD = "admin";
|
||||||
|
|
||||||
class BlogOAuth : public std::vector<const Wt::Auth::OAuthService *> {
|
class BlogOAuth : public std::vector<const Wt::Auth::OAuthService *> {
|
||||||
public:
|
public:
|
||||||
~BlogOAuth() {
|
~BlogOAuth() {
|
||||||
@ -20,6 +28,46 @@ BlogOAuth blogOAuth;
|
|||||||
|
|
||||||
BlogSession::BlogSession(Wt::Dbo::SqlConnectionPool &connectionPool)
|
BlogSession::BlogSession(Wt::Dbo::SqlConnectionPool &connectionPool)
|
||||||
: m_connectionPool(connectionPool), m_users(*this) {
|
: m_connectionPool(connectionPool), m_users(*this) {
|
||||||
|
setConnectionPool(m_connectionPool);
|
||||||
|
mapClass<Comment>("comment");
|
||||||
|
mapClass<Post>("post");
|
||||||
|
mapClass<Tag>("tag");
|
||||||
|
mapClass<Token>("token");
|
||||||
|
mapClass<User>("user");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Wt::Dbo::Transaction t(*this);
|
||||||
|
createTables();
|
||||||
|
Wt::Dbo::ptr<User> admin = add(std::make_unique<User>());
|
||||||
|
User *a = admin.modify();
|
||||||
|
a->name = ADMIN_USERNAME;
|
||||||
|
a->role = User::Admin;
|
||||||
|
|
||||||
|
Wt::Auth::User authAdmin = m_users.findWithIdentity(Wt::Auth::Identity::LoginName, a->name);
|
||||||
|
blogPasswords.updatePassword(authAdmin, ADMIN_PASSWORD);
|
||||||
|
|
||||||
|
Wt::Dbo::ptr<Post> post = add(std::make_unique<Post>());
|
||||||
|
Post *p = post.modify();
|
||||||
|
|
||||||
|
p->state = Post::Published;
|
||||||
|
p->author = admin;
|
||||||
|
p->title = "Welcome!";
|
||||||
|
p->briefSrc = "Welcome to your own blog.";
|
||||||
|
p->bodySrc = "We have created for you an " + ADMIN_USERNAME + " user with password " + ADMIN_PASSWORD;
|
||||||
|
p->briefHtml = asciidoc(p->briefSrc);
|
||||||
|
p->bodyHtml = asciidoc(p->bodySrc);
|
||||||
|
p->date = Wt::WDateTime::currentDateTime();
|
||||||
|
|
||||||
|
Wt::Dbo::ptr<Comment> rootComment = add(std::make_unique<Comment>());
|
||||||
|
rootComment.modify()->post = post;
|
||||||
|
|
||||||
|
t.commit();
|
||||||
|
|
||||||
|
LOG(info) << "Created database, and user " << ADMIN_USERNAME << " / " << ADMIN_PASSWORD << std::endl;
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
LOG(error) << e.what() << std::endl;
|
||||||
|
LOG(info) << "Using existing database";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlogSession::configureAuth() {
|
void BlogSession::configureAuth() {
|
||||||
|
Loading…
Reference in New Issue
Block a user