剪藏#剪藏#请叫我卤菜

20、Docker Compose项目实战-搭建自己的新闻网站

2025 年 8 月 18 日1 分钟
分享Twitter / XTelegram微博
20、Docker Compose项目实战-搭建自己的新闻网站 封面

纸上得来终觉浅,绝知此事要躬行

Notion image

今天要和小伙伴们分享的就是搭建自己的新闻网站,在网上搜了搜 最终选择了newsnow这个github开源项目

https://github.com/ourongxing/newsnow

Notion image

废话不多说 我们直接开始 源码中也有相应的docker compose 配置 我们大体看一下

Notion image

Notion image

目前看好像有几种方式,一个是默认的sqlite 一个是mysql 基于我们极简的部署方式,我们就用默认的sqlite部署即可 不需要在用mysql了,那我们配置下我们的docker compose open yml文件

Notion image

其中如果我们想配置github登录的话 得在github操作一下 获取相关的clientid 和 clientsecret 怎么获取呢 也很简单

Notion image

Notion image

Notion image

我们创建完以后 就可以看到相关的clientid 和 clientsecret

Notion image

clientsecret只会显示一次,所以把他保存起来 我们docker compose 配置需要这个,我们在.env 配置下即可

Notion image

docker compose open配置完了以后 这地方有个点要注意一下,我用了源码给出的这个docker compose 这个image镜像实在是太慢了 所以我换了另一个镜像 直接瞬间秒拉

Notion image

将上面的image换成下面的 直接秒拉

ghcr.nju.edu.cn/ourongxing/newsnow:latest

Notion image

那我们在配置一下我们的nginx吧 我们还是通过子域名的方式访问

Notion image

我们重启一下nginx容器,同时我们重新构建一下这个news容器

JAVASCRIPT
docker-compose -f docker-compose.open.yml up -

我们看一下容器列表 可以看到 他正常运行起来了

Notion image

那我们访问下 我们的子域名 看看能有啥效果不,可以看到已经出来了

Notion image

在最热里边 有很多的新闻 知乎、微博、抖音等等 基本上囊括了国内主流新闻,如果你在最热里边没有找到你需要的,点击这个更多 可以看到更多的

Notion image

对于你想要的特别留意关注的,可以点击关注,关注一下 后续可以在关注里边看到

Notion image

同时你也可以根据自己的需求进行排版,每个卡片都有拖动的图标 直接拖动即可

Notion image

同时这个网站可以看实时刷新 或者一键刷新获取最新的新闻

Notion image

之前我们说了 我们可以登录github账号 那我们也可以直接登录github 这样后续我们用github账号登录,

Notion image

Notion image

Notion image

结果github登录报错了 我的天 啥情况 开始看看部署文档 查找资料

Notion image

Notion image

我的域名是 http://www.news.lulifa.com 我写成了new 这个回调url得加上api 我默认就没加 全部加上看看

Notion image

有报错了 这次直接爆出问题响应代码了 啥情况。。。。

Notion image

Notion image

我再试试 又可以了 感觉这个网络有点无问题,好吧我最终排查了下 应该是我科学上网的代理不稳定导致的,正常是没问题的

Notion image

好了 我们现在就可以看新闻了 不用看这个新闻那个新闻了 直接访问这个页面 想看什么看什么 最好是放在自己的关注里 同时也支持浅色模式

Notion image

喜欢的小伙伴赶快试试吧

Notion image

原文地址: https://mp.weixin.qq.com/s?__biz=MzI4MzY0NDU2NA==&mid=2247485405&idx=1&sn=d3a26a323582bd761b22891100c21f0d&chksm=eab455cfa97627e94fe815de1549d344b887a7c5c58af3646ad653b1e441922d18568e671183&mpshare=1&scene=1&srcid=08181TbwoPmGL1bi88OIK2PP&sharer_shareinfo=b3d43c402ee8bfea0e45e230a4acdd29&sharer_shareinfo_first=b3d43c402ee8bfea0e45e230a4acdd29#rd

相关文章