jiangnianshun/django-mdict

Could possible to create a docker for it?

wswv opened this issue · 5 comments

wswv commented

Hi, thanks for your hard work!

Could it possible to create a docker for it, thanks!

我没有用过docker,我会尝试制作一下,大约在这个周末。

wswv commented

Thanks for your quick reply!
The service implement as docker is easy way for most people, it will help people who need it.

ubuntu20.04
Dockerfile

FROM python:3.8
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
RUN apt-get update
RUN pip install pip -U
RUN apt-get install -y zlib1g-dev liblzo2-dev python3-xapian libxapian-dev
ADD requirements1.txt /code/
ADD requirements2.txt /code/
RUN pip install -r requirements1.txt
RUN pip install -r requirements2.txt
ADD . /code/

docker-compose.yml

version: "3"
services:
 app:
  restart: always
  build: .
  command: "python3 manage.py runserver 0.0.0.0:8000 --noreload"
  volumes:
   - .:/code
   - /home/jns/Documents/mdict:/code/media/mdict/doc
  ports:
   - "8000:8000"

先运行run_server_apt.sh进行初始化生成db.sqlite3数据库
将路径/home/jns/Documents/mdict替换为本地词典库路径(绝对路径),运行

docker-compose up

存在问题:

  1. 镜像体积非常大;
  2. 词典内容能正常显示,但是词典封面图无法显示。

目前还没有学懂,后续再慢慢修改吧。

wswv commented

About the docker base image, you can use alpine image, which size is lower, here are some link for your reference:
https://github.com/linuxserver/docker-baseimage-alpine //You can find some docker file from it.
https://www.techtarget.com/searchitoperations/tutorial/Use-Docker-and-Alpine-Linux-to-build-lightweight-containers

I'll try to build some by myself later too.

感谢回复,我后续进一步学习和修改。