我有一个撰写文件,如下所示:
version: "3"
services:
oj-redis:
image: redis:4.0-alpine
container_name: oj-redis
restart: always
volumes:
- ./data/redis:/data
oj-postgres:
image: postgres:10-alpine
container_name: oj-postgres
restart: always
volumes:
- ./data/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_DB=onlinejudge
- POSTGRES_USER=onlinejudge
- POSTGRES_PASSWORD=onlinejudge
judge-server:
image: <image-name>
container_name: judge-server
restart: always
read_only: true
cap_drop:
- SETPCAP
- MKNOD
- NET_BIND_SERVICE
- SYS_CHROOT
- SETFCAP
- FSETID
tmpfs:
- /tmp
volumes:
- ./data/backend/test_case:/test_case:ro
- ./data/judge_server/log:/log
- ./data/judge_server/run:/judger
environment:
- SERVICE_URL=http://judge-server:8080
- BACKEND_URL=http://oj-backend:8000/api/judge_server_heartbeat/
- TOKEN=CHANGE_THIS
# - judger_debug=1
oj-backend:
image: <image-name>
container_name: oj-backend
restart: always
depends_on:
- oj-redis
- oj-postgres
- judge-server
volumes:
- ./data/backend:/data
environment:
- POSTGRES_DB=onlinejudge
- POSTGRES_USER=onlinejudge
- POSTGRES_PASSWORD=onlinejudge
- JUDGE_SERVER_TOKEN=CHANGE_THIS
- PROCTOR_URL=http://localhost:3000
# - FORCE_HTTPS=1
# - STATIC_CDN_HOST=cdn.oj.com
ports:
- "0.0.0.0:80:8000"
- "0.0.0.0:443:1443"
每当我在docker hub上构建一个新映像并使用docker-compose up -d
拉动它时,oj-backend
容器的某些部分就会更新,而其他部分则不会。当我访问某些API时,它们会从旧版本返回数据。我发现的唯一解决方案是rm -rf
卷目录data
并再次运行docker-compose up
。
我检查了容器,并更新了所有文件,所以我不确定这是怎么发生的。
我需要生产环境中已挂载目录中的数据,因此无法删除它并从头开始。
这是oj-backend
的dockerfile
FROM python:3.7-alpine3.9
ENV OJ_ENV production
ADD . /app
WORKDIR /app
HEALTHCHECK --interval=5s --retries=3 CMD python2 /app/deploy/health_check.py
RUN apk add --update --no-cache build-base nginx openssl curl unzip supervisor libffi-dev jpeg-dev zlib-dev postgresql-dev freetype-dev && \
pip install --no-cache-dir -r /app/deploy/requirements.txt && \
apk del build-base --purge
RUN curl -L $(curl -s https://api.github.com/repos/steviekong/OnlineJudgeFE/releases/tags/oj_2.7.0-beta.2 | grep /dist.zip | cut -d '"' -f 4) -o dist.zip && \
unzip dist.zip && \
rm dist.zip
ENTRYPOINT /app/deploy/entrypoint.sh
这是一台django服务器。