File size: 1,409 Bytes
6a52c11
 
 
ddaa426
 
 
 
 
 
 
 
 
 
6a52c11
 
 
 
 
 
ddaa426
 
 
6a52c11
ddaa426
 
 
 
6a52c11
ddaa426
 
6a52c11
 
 
 
ddaa426
 
 
 
 
 
 
 
6a52c11
ddaa426
 
 
6a52c11
 
 
 
 
ddaa426
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
# Get a distribution that has uv already installed
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    curl \
    build-essential \
    && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && npm install -g yarn \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Add user - this is the user that will run the app
RUN useradd -m -u 1000 user
USER user

# Set the home directory and path
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:/home/user/.cargo/bin:$PATH \
    PATH=$HOME/app/node_modules/.bin:$PATH \
    PATH=$HOME/app/.venv/bin:$PATH

# Install Rust for the user and set up shell
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
    && echo 'source $HOME/.cargo/env' >> $HOME/.bashrc \
    && /bin/bash -c 'source $HOME/.cargo/env'

# Use bash as the default shell
SHELL ["/bin/bash", "-c"]

# Set the working directory
WORKDIR $HOME/app

# Copy package files first
COPY --chown=user package.json yarn.lock ./

# Install dependencies
RUN yarn install

# Copy the rest of the app
COPY --chown=user . .

# Install Python dependencies
RUN source $HOME/.cargo/env && uv sync --frozen
RUN source .venv/bin/activate

# Expose the port
EXPOSE 7860

# Run the app
CMD yarn build && uv run uvicorn server:app --host 0.0.0.0 --port 7860