inf04-web2/Dockerfile

92 lines
3.0 KiB
Docker
Raw Normal View History

2024-06-20 19:10:59 +00:00
# Choose a base image. Debian is a good choice due to pyenv
FROM debian:latest
# Update the package list and install necessary dependencies
RUN apt-get update && apt-get install -y \
aptitude \
tmux vim-nox nano mc git curl termshark procps \
sudo iproute2 iputils-ping bridge-utils \
ifupdown udev make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget llvm libncurses5-dev \
libncursesw5-dev xz-utils libffi-dev liblzma-dev \
sqlite3 default-libmysqlclient-dev pkg-config \
npm
# Set password for root user (optional, for configuration)
RUN echo 'root:rootpass' | chpasswd
# Add a new user `user` with password `pass` and prepare the environment
RUN useradd -m user && echo 'user:pass' | chpasswd && adduser user sudo
# Switch to user `user`
USER user
WORKDIR /home/user
# Install pyenv
RUN git clone https://github.com/pyenv/pyenv .pyenv
# Install pyenv-virtualenv
RUN git clone https://github.com/pyenv/pyenv-virtualenv .pyenv/plugins/pyenv-virtualenv
# Set environment variables
ENV HOME /home/user
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
# Add pyenv and pyenv-virtualenv configuration to .bashrc
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> .bashrc
RUN echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> .bashrc
RUN echo 'eval "$(pyenv init -)"' >> .bashrc
RUN echo 'eval "$(pyenv virtualenv-init -)"' >> .bashrc
# Install Python 3.11 with --enable-shared
RUN bash -i -c "source ~/.bashrc && env PYTHON_CONFIGURE_OPTS='--enable-shared' pyenv install 3.11"
# Create a virtual environment p3.11
RUN bash -i -c "source ~/.bashrc && pyenv virtualenv 3.11 p3.11"
# Set p3.11 as the default virtual environment
RUN bash -i -c "source ~/.bashrc && pyenv local p3.11"
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
# Add Poetry path to PATH directly in the Dockerfile
ENV PATH="$HOME/.local/bin:$PATH"
# Install SQLAlchemy and MySQL adapter in the pyenv environment
RUN bash -i -c "source ~/.bashrc && pyenv activate p3.11 && pip install \
sqlalchemy mysqlclient mysql-connector-python\
ipython numpy scipy matplotlib \
biopython"
# Copy the project into the image
COPY --chown=user:user . /home/user/fapi
COPY ./_confs/* ./
# Set the working directory for installing dependencies
WORKDIR /home/user/fapi
# Install project dependencies with Poetry in the p3.11 environment
RUN bash -i -c "source ~/.bashrc && pyenv activate p3.11 && poetry install"
#RUN bash -i -c "source ~/.bashrc && poetry config virtualenvs.create false && poetry install"
# Copy the .vimrc file
#COPY --chown=user:user .vimrc /home/user/.vimrc
# Install vim-plug using curl
RUN curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Install Vim plugins
RUN vim +PlugInstall +qall
# Run the application
#CMD ["/bin/bash", "-c", "python entrypoint.py"]
# Run Bash
CMD ["/bin/bash"]