-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (37 loc) · 1.63 KB
/
Dockerfile
File metadata and controls
51 lines (37 loc) · 1.63 KB
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
46
47
48
49
50
51
ARG SUNDIALS_VERSION=5.1.0
ARG GLPK_VERSION=4.65
ARG EXTRAS="dfba"
FROM ghcr.io/amyris/sundials-glpk-pybind:sundials-${SUNDIALS_VERSION}-glpk-${GLPK_VERSION} as dev
COPY --from=ghcr.io/astral-sh/uv:0.6.11 /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
WORKDIR /app
COPY pyproject.toml ./
RUN EXTRA_NAMES=$(echo $EXTRAS | sed 's/,/ --extra /g' | sed 's/^/--extra /')
RUN echo ${EXTRA_NAMES}
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project ${EXTRA_NAMES}
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv uv sync --frozen ${EXTRA_NAMES}
ENV PATH="/app/.venv/bin:$PATH"
FROM dev as vscode
ARG USERNAME=vscode
# USER_UID and USER_GID are important - it should match your host's
# user UID and GID. Usually, these are 1000 so it doesn't need to be changed.
# See https://code.visualstudio.com/docs/remote/containers-advanced#_adding-a-nonroot-user-to-your-dev-container
# for more info.
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
sudo git openssh-client vim \
&& groupadd --gid $USER_GID $USERNAME \
&& useradd --no-log-init --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& chown -R $USER_UID:$USER_GID /app
USER $USERNAME