-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (66 loc) · 2.39 KB
/
Dockerfile
File metadata and controls
84 lines (66 loc) · 2.39 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Stage 1: Development stage for Python dependencies
FROM python:3.12-slim AS dep-stage
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV UV_PYTHON_DOWNLOADS=0
ENV VIRTUAL_ENV=/app/venv
# Set up app dir
WORKDIR /tmp
# Copy project files over
COPY ./pyproject.toml ./uv.lock ./
# Install system prereq packages
RUN apt-get update && \
apt-get install -y \
build-essential \
git \
# these are for h5py in sdss_explorer
curl libhdf5-dev pkg-config \
# these are for vaex
gcc g++ libboost-all-dev \
libffi-dev python3-dev libxml2-dev libxslt-dev \
libpq-dev zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Rust for sdss_explorer
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && . /root/.cargo/env
ENV PATH="/root/.cargo/bin:$PATH"
# Add a command to check if cargo is available
RUN cargo --version
# setup correct wheels for vaex
# normal build hangs/fails like https://github.com/vaexio/vaex/issues/2382
# temp solution, see https://github.com/vaexio/vaex/pull/2331
ENV PIP_FIND_LINKS=https://github.com/ddelange/vaex/releases/expanded_assets/core-v4.17.1.post4
RUN pip install --force-reinstall vaex
ENV PIP_FIND_LINKS=
# Installing uv and then project dependencies
RUN pip install uv
RUN uv venv /app/venv # make venv
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev --extra solara
# Stage 2: Development stage for the project
FROM dep-stage AS dev-stage
ARG VALIS_ENV="production"
# Copy the main project files over and install
COPY ./ ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --extra solara
# Create dir for socket and logs
RUN mkdir -p /tmp/webapp
# Setting environment variables
# these can be manually overridden
ENV MODULE_NAME="valis.wsgi"
ENV VALIS_SOCKET_DIR='/tmp/webapp'
ENV VALIS_LOGS_DIR='/tmp/webapp'
ENV VALIS_ALLOW_ORIGIN="https://data.sdss5.org/zora/"
ENV VALIS_DB_REMOTE=True
ENV VALIS_ENV=$VALIS_ENV
ENV SOLARA_CHECK_HOOKS="off"
# Stage 3: Build stage (inherits from dev-stage)
FROM dev-stage AS build-stage
# Set a label
LABEL org.opencontainers.image.source=https://github.com/sdss/valis
LABEL org.opencontainers.image.description="valis ${VALIS_ENV} image"
# Expose the port
EXPOSE 8000
# Start the FastAPI app for production
CMD ["uv", "run", "gunicorn", "-c", "python/valis/wsgi_conf.py", "valis.wsgi:app"]