baxin commited on
Commit
a20ad5f
·
verified ·
1 Parent(s): 6177b90

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -61
Dockerfile CHANGED
@@ -1,81 +1,58 @@
1
- # Use the base image from kojikno/ot-robot-server
2
-
3
  FROM kojikno/ot-robot-server:v1.2
4
 
 
5
 
6
- # Set environment variables for pyenv
7
- ENV HOME /root
8
- ENV PYENV_ROOT $HOME/.pyenv
9
- ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
 
 
 
 
10
 
11
- # Initialize pyenv
12
- RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
13
- RUN echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
14
- RUN echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
15
- RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc
16
 
17
- RUN apt-get install libudev-dev
 
 
 
18
 
19
- # Set the working directory
20
  WORKDIR /root/opentrons
21
- # EXPOSE 31950
22
- RUN ls
23
-
24
- # Run chat UI
25
- # RUN /bin/bash -c "source ~/.bashrc && pyenv install 3.8.5"
26
- # RUN /bin/bash -c "source ~/.bashrc && pyenv global 3.8.5"
27
- # RUN /bin/bash -c "source ~/.bashrc && pip install gradio"
28
- # RUN /bin/bash -c "source ~/.bashrc && python app.py"
29
-
30
- # Run make command in robot-server directory
31
- # RUN /bin/bash -c "source ~/.bashrc && make -C robot-server dev"
32
- # RUN /bin/bash -c "source ~/.bashrc && make robot-server setup"
33
- # Install yarn
34
-
35
- # RUN /bin/bash -c "source ~/.bashrc && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list && apt-get update && apt-get install -y yarn"
36
-
37
- # ENV NODE_VERSION 16.18.0
38
- # # Install nvm with node and npm
39
- # RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh | bash \
40
- # && . $NVM_DIR/nvm.sh \
41
- # && nvm install $NODE_VERSION \
42
- # && nvm alias default $NODE_VERSION \
43
- # && nvm use default
44
-
45
- # Set up PATH so that Node.js and npm can be found
46
- # ENV PATH $NVM_DIR/versions/node/v16.18.0/bin:$PATH
47
-
48
- # Install systemd
49
- RUN apt-get update && apt-get install -y libsystemd-dev
50
-
51
- # Run make command in robot-server directory
52
- RUN /bin/bash -c "source ~/.bashrc && make -C robot-server setup"
53
 
 
 
 
54
 
55
- # Set up a new user named "user" with user ID 1000
56
  RUN useradd -m -u 1000 user
57
-
58
- # Switch to the "user" user
59
  USER user
60
-
61
- # Set home to the user's home directory
62
  ENV HOME=/home/user \
63
  PATH=/home/user/.local/bin:$PATH
64
 
65
- # Set the working directory to the user's home directory
66
  WORKDIR $HOME/app
67
 
68
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
 
 
 
 
 
 
 
69
  COPY --chown=user . $HOME/app
70
- # CMD ["pip" "install", "-r", "requirements"]
71
- USER root
72
- RUN pip install -r requirements.txt
73
 
74
- #USER user
75
- COPY --chown=root . $HOME/app
76
- # CMD ["python", "main.py"]
 
77
  COPY entrypoint.sh /entrypoint.sh
78
- RUN chmod +x entrypoint.sh
 
79
  WORKDIR /root/opentrons
80
- # ENTRYPOINT ["#!/bin/bash", "-c", "entrypoint.sh"]
81
- ENTRYPOINT ["source", "entrypoint.sh"]
 
 
 
1
  FROM kojikno/ot-robot-server:v1.2
2
 
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
 
5
+ # ---- system deps ----
6
+ RUN apt-get update \
7
+ && apt-get install -y --no-install-recommends \
8
+ libudev-dev \
9
+ libsystemd-dev \
10
+ curl \
11
+ ca-certificates \
12
+ && rm -rf /var/lib/apt/lists/*
13
 
14
+ # ---- install uv ----
15
+ # installs to /root/.local/bin/uv by default
16
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
17
+ ENV PATH=/root/.local/bin:$PATH
 
18
 
19
+ # ---- install Python (replace pyenv) ----
20
+ # pin python version you need
21
+ ARG PYTHON_VERSION=3.8.5
22
+ RUN uv python install ${PYTHON_VERSION}
23
 
24
+ # working dir for opentrons repo in base image
25
  WORKDIR /root/opentrons
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ # if robot-server setup needs python, make sure it uses uv's python
28
+ # (This uses uv's managed interpreter directly)
29
+ RUN uv run --python ${PYTHON_VERSION} make -C robot-server setup
30
 
31
+ # ---- app user ----
32
  RUN useradd -m -u 1000 user
 
 
33
  USER user
 
 
34
  ENV HOME=/home/user \
35
  PATH=/home/user/.local/bin:$PATH
36
 
 
37
  WORKDIR $HOME/app
38
 
39
+ # copy only requirements first for docker layer caching
40
+ COPY --chown=user requirements.txt $HOME/app/requirements.txt
41
+
42
+ # create venv + install deps (in user's home)
43
+ RUN uv venv --python ${PYTHON_VERSION} .venv \
44
+ && uv pip install --python .venv/bin/python -r requirements.txt
45
+
46
+ # now copy the rest
47
  COPY --chown=user . $HOME/app
 
 
 
48
 
49
+ # ---- entrypoint ----
50
+ # IMPORTANT: ENTRYPOINT cannot "source" directly
51
+ # use bash -lc so "source" works and env is loaded
52
+ USER root
53
  COPY entrypoint.sh /entrypoint.sh
54
+ RUN chmod +x /entrypoint.sh
55
+
56
  WORKDIR /root/opentrons
57
+ ENTRYPOINT ["/bin/bash", "-lc", "source /entrypoint.sh && exec \"$@\""]
58
+ CMD ["bash"]