Docker compile python file in Dockerfile don’t create pyc
I would compile my python file (.py) in Dockerfile for create pyc file and then delete all *.py.
I create a Dockerfile like tisone:
FROM python:3.6-alpine
EXPOSE 8000
RUN apk update
RUN apk add --no-cache make linux-headers libffi-dev jpeg-dev zlib-dev
RUN apk add postgresql-dev gcc python3-dev musl-dev
VOLUME /var/lib/cathstudio/data
WORKDIR /var/lib/cathstudio/data
COPY ./requirements.txt .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
ENV PYTHONUNBUFFERED 1
#ENV PYTHONPATH /var/lib/cathstudio/data
COPY . /var/lib/cathstudio/data
RUN python -m compileall ajaxfuncs/
well, when i build my image compilation seems to be done:
but when i browse my file in volumes no pyc file are present:
How can i compile my python file during docker build for having the pyc s?
So many thanks in advance
Source: StackOverflow