-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
51 lines (43 loc) · 1.8 KB
/
Dockerfile
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
# SPDX-FileCopyrightText: 2021 The eminus developers
# SPDX-License-Identifier: Apache-2.0
# Build everything using multi-stage builds
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS build
# Create a working directory and Python environment
WORKDIR /usr/app/
RUN uv venv /usr/app/venv/
ARG PATH="/usr/app/venv/bin:$PATH"
# Install Git to clone repositories and clean up afterwards
RUN apt-get update -y \
&& apt-get install -y git --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Torch manually since we only want to compute on the CPU
RUN uv pip install torch --index-url https://download.pytorch.org/whl/cpu --no-cache-dir \
# Needed to get Torch to work (for now)
&& uv pip install typing-extensions --upgrade --no-cache-dir
# Install eminus with all extras available
# Use an editable installation so users can make changes on the fly
# We can pass the branch name when building the image but default to the main branch
ARG BRANCH=main
RUN git clone -b ${BRANCH} https://gitlab.com/wangenau/eminus.git \
&& uv pip install -e eminus/[all,dev] --no-cache-dir
# Set up the application stage
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
LABEL maintainer="wangenau"
# Ensure that no root rights are being used, copy the environment and eminus source
RUN addgroup --system eminus \
&& adduser --system --group eminus \
&& mkdir /usr/app/ \
&& chown eminus:eminus /usr/app/ \
&& mkdir /nonexistent/ \
&& chown eminus:eminus /nonexistent/
WORKDIR /usr/app/
COPY --chown=eminus:eminus --from=build /usr/app/ /usr/app/
# Set the working directory and set variables
WORKDIR /usr/app/eminus/
ENV PATH="/usr/app/venv/bin:$PATH"
ENV JUPYTER_PLATFORM_DIRS=1
# Set user, expose port, and run Jupyter
USER eminus
EXPOSE 8888
CMD ["sh", "-c", "jupyter lab . --no-browser --ip 0.0.0.0 --port 8888"]