我需要在由DockerFile + DockerCompose + bash脚本启动的Python Django环境中安装PyWikiBot。
如果可能的话,我想在docker-compose up执行期间自动登录PyWikiBot。
一切准备就绪并且可以正常工作。我已将PyWikiBot包含在Django体系结构的lib文件夹中,以便可以将其导入我的应用程序代码中。不知道如何使登录自动化
docker-compose.yml
class ParentModel(models.Model):
someModel = models.EmbeddedModelField(
model_container=SomeModel
)
def __str__(self):
return "{}".format(self.someModel)
应用程序/Dockerfile.app
version: '3'
(...)
app:
build:
context: app
dockerfile: Dockerfile.app
restart: unless-stopped
env_file:
- ./.env
volumes:
- ./app:/srv/code
- static-files:/srv/static
- media-files:/srv/media
networks:
- backend
- frontend
depends_on:
- db
- redis
app / config / start.sh
FROM python:3.7
# Settle Django directory
WORKDIR /srv/code
ADD . /srv/code
RUN apt-get update && apt-get upgrade -y
# Install application requirements
RUN pip install --upgrade pip
RUN pip3 install -r /srv/code/config/requirements.txt
# Add uWSGI config
ADD ./config/django-uwsgi.ini /etc/uwsgi/django-uwsgi.ini
# Create django user, will own the Django app. This is needed
# because we defined this, in the uwsgi.ini file
RUN adduser --no-create-home --disabled-login --group --system django
RUN chown -R django:django /srv/code
# Execute start script to launch uWSGI, Django & Cron backups
CMD ["/srv/code/config/start.sh"]
目前,我可以在Docker中进入PyWikiBot目录并手动安装它,但是我不知道如何在内部自动登录以进行下一次启动。如果您有个主意?