File size: 1,431 Bytes
9ff0a35 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
FROM julia:1.10.4
# Install python requirements for the project as root
RUN apt-get update && apt-get install -y python3 python3-pip python3-venv
# Create a non-root user
RUN useradd --create-home --shell /bin/bash user
RUN mkdir /home/user/app
WORKDIR /home/user/app
RUN chown -R user:user /home/
USER user
# Copy only the requirements file to leverage Docker cache
COPY --chown=user requirements.txt /home/user/app/requirements.txt
# Install pinecone and other Python dependencies as non-root user
RUN python3 -m venv /home/user/venv && \
/home/user/venv/bin/pip install -r /home/user/app/requirements.txt
# Copy the rest of the application code
COPY --chown=user . /home/user/app
# Copy the data to the container
COPY --chown=user data /home/user/data
# Activate the virtual environment
RUN echo 'export PATH="/home/user/venv/bin:$PATH"' >> /home/user/.bashrc
RUN mkdir -p /home/user/.julia/config && \
echo 'ENV["PYTHON"] = "/home/user/venv/bin/python"' >> /home/user/.julia/config/startup.jl
RUN mkdir -p /home/user/.julia/config
#COPY startup.jl /home/user/.julia/config/startup.jl
# Ensure the virtual environment is activated
RUN /home/user/venv/bin/pip install --upgrade pip
# Expose the port
EXPOSE 8000
EXPOSE 80
ENV JULIA_DEPOT_PATH "/home/user/.julia"
RUN julia -e 'using Pkg; Pkg.activate("."); Pkg.precompile()'
ENTRYPOINT julia --project -e 'using Pkg; Pkg.instantiate(); include("server.jl")' |