后端移动文件夹,前端在docker中编译,进一步减小镜像大小
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
*.md
|
||||||
|
.idea
|
||||||
|
.git
|
||||||
+17
-4
@@ -1,13 +1,26 @@
|
|||||||
FROM python:3.9.5-alpine
|
FROM node:18-alpine as webui
|
||||||
|
COPY . /app
|
||||||
|
WORKDIR /app/fcb-fronted/
|
||||||
|
ENV NPM_CONFIG_LOGLEVEL=verbose
|
||||||
|
RUN npm i
|
||||||
|
RUN npm run build-only
|
||||||
|
# 似乎需要把文件移动才能正常
|
||||||
|
RUN mv dist/logo_small.png dist/assets/
|
||||||
|
|
||||||
|
|
||||||
|
FROM python:3.9.5-alpine as FileCodeBox
|
||||||
LABEL author="Lan"
|
LABEL author="Lan"
|
||||||
LABEL email="vast@tom.com"
|
LABEL email="vast@tom.com"
|
||||||
LABEL version="6"
|
LABEL version="6"
|
||||||
|
|
||||||
|
|
||||||
COPY . /app
|
# 先安装依赖可以产生缓存
|
||||||
|
WORKDIR /app
|
||||||
|
COPY requirements.txt /app
|
||||||
|
RUN /usr/local/bin/python -m pip install --upgrade pip && pip install -r requirements.txt
|
||||||
|
COPY ./backend/ /app
|
||||||
|
COPY --from=webui /app/fcb-fronted/dist/ /app/dist
|
||||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
RUN echo 'Asia/Shanghai' >/etc/timezone
|
RUN echo 'Asia/Shanghai' >/etc/timezone
|
||||||
WORKDIR /app
|
|
||||||
RUN pip install -r requirements.txt
|
|
||||||
EXPOSE 12345
|
EXPOSE 12345
|
||||||
CMD ["python","main.py"]
|
CMD ["python","main.py"]
|
||||||
@@ -31,20 +31,20 @@ app.add_middleware(
|
|||||||
async def assets(file_path: str):
|
async def assets(file_path: str):
|
||||||
if settings.max_save_seconds > 0:
|
if settings.max_save_seconds > 0:
|
||||||
if re.match(r'SendView-[\d|a-f|A-F]+\.js', file_path):
|
if re.match(r'SendView-[\d|a-f|A-F]+\.js', file_path):
|
||||||
with open(BASE_DIR / f'./fcb-fronted/dist/assets/{file_path}', 'r', encoding='utf-8') as f:
|
with open(BASE_DIR / f'./dist/assets/{file_path}', 'r', encoding='utf-8') as f:
|
||||||
# 删除永久保存选项
|
# 删除永久保存选项
|
||||||
content = f.read()
|
content = f.read()
|
||||||
content = content.replace('_(c,{label:e(r)("send.expireData.forever"),value:"forever"},null,8,["label"]),', '')
|
content = content.replace('_(c,{label:e(r)("send.expireData.forever"),value:"forever"},null,8,["label"]),', '')
|
||||||
return HTMLResponse(content=content, media_type='text/javascript')
|
return HTMLResponse(content=content, media_type='text/javascript')
|
||||||
if re.match(r'index-[\d|a-f|A-F]+\.js', file_path):
|
if re.match(r'index-[\d|a-f|A-F]+\.js', file_path):
|
||||||
with open(BASE_DIR / f'./fcb-fronted/dist/assets/{file_path}', 'r', encoding='utf-8') as f:
|
with open(BASE_DIR / f'./dist/assets/{file_path}', 'r', encoding='utf-8') as f:
|
||||||
# 更改本文描述
|
# 更改本文描述
|
||||||
desc_zh, desc_en = await max_save_times_desc(settings.max_save_seconds)
|
desc_zh, desc_en = await max_save_times_desc(settings.max_save_seconds)
|
||||||
content = f.read()
|
content = f.read()
|
||||||
content = content.replace('天数<7', desc_zh)
|
content = content.replace('天数<7', desc_zh)
|
||||||
content = content.replace('Days <7', desc_en)
|
content = content.replace('Days <7', desc_en)
|
||||||
return HTMLResponse(content=content, media_type='text/javascript')
|
return HTMLResponse(content=content, media_type='text/javascript')
|
||||||
return FileResponse(f'./fcb-fronted/dist/assets/{file_path}')
|
return FileResponse(f'./dist/assets/{file_path}')
|
||||||
|
|
||||||
|
|
||||||
register_tortoise(
|
register_tortoise(
|
||||||
@@ -79,7 +79,7 @@ async def startup_event():
|
|||||||
@app.get('/')
|
@app.get('/')
|
||||||
async def index():
|
async def index():
|
||||||
return HTMLResponse(
|
return HTMLResponse(
|
||||||
content=open(BASE_DIR / './fcb-fronted/dist/index.html', 'r', encoding='utf-8').read()
|
content=open(BASE_DIR / './dist/index.html', 'r', encoding='utf-8').read()
|
||||||
.replace('{{title}}', str(settings.name))
|
.replace('{{title}}', str(settings.name))
|
||||||
.replace('{{description}}', str(settings.description))
|
.replace('{{description}}', str(settings.description))
|
||||||
.replace('{{keywords}}', str(settings.keywords))
|
.replace('{{keywords}}', str(settings.keywords))
|
||||||
Reference in New Issue
Block a user