# define an alias for the specfic python version used in this file. FROM python:3.9.12-slim-bullseye as python # Python build stage FROM python as python-build-stage ARG BUILD_ENVIRONMENT=prod # Install apt packages RUN apt-get update && apt-get install --no-install-recommends -y \ # dependencies for building Python packages build-essential \ # psycopg2 dependencies libpq-dev \ default-libmysqlclient-dev \ libffi-dev \ libjpeg-dev \ libxml2 \ libxslt1-dev # Requirements are installed here to ensure they will be cached. COPY ./requirements . # Create Python Dependency and Sub-Dependency Wheels. RUN pip wheel --wheel-dir /usr/src/app/wheels \ -r ${BUILD_ENVIRONMENT}.txt -i https://pypi.tuna.tsinghua.edu.cn/simple # Python 'run' stage FROM python as python-run-stage LABEL title="Music Tag Web | 音乐标签网页版" LABEL description="『音乐标签』Web版是一款可以编辑歌曲的标题,专辑,艺术家,歌词,封面等信息的应用程序" LABEL authors="xhongc" ARG BUILD_ENVIRONMENT=prod ARG APP_HOME=/app ENV PYTHONUNBUFFERED 1 ENV PYTHONDONTWRITEBYTECODE 1 ENV BUILD_ENV ${BUILD_ENVIRONMENT} WORKDIR ${APP_HOME} # Install required system dependencies RUN apt-get update && apt-get install --no-install-recommends -y \ # psycopg2 dependencies libpq-dev \ # Translations dependencies gettext \ default-libmysqlclient-dev \ nodejs\ # cleaning up unused files && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* # All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction # copy python dependency wheels from python-build-stage COPY --from=python-build-stage /usr/src/app/wheels /wheels/ # use wheels to install python dependencies RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \ && rm -rf /wheels/ COPY ./compose/prod/django/start /start RUN sed -i 's/\r$//g' /start RUN chmod +x /start COPY ./compose/prod/django/celery/worker/start /start-celeryworker RUN sed -i 's/\r$//g' /start-celeryworker RUN chmod +x /start-celeryworker COPY ./compose/prod/django/celery/beat/start /start-celerybeat RUN sed -i 's/\r$//g' /start-celerybeat RUN chmod +x /start-celerybeat # copy application code to WORKDIR COPY . ${APP_HOME} RUN python setup_in_docker.py CMD ["/start"]