File size: 1,778 Bytes
6425b43
df069ee
52938ea
6425b43
52938ea
 
6425b43
52938ea
 
c32b98e
52938ea
c32b98e
52938ea
 
 
475d2b0
 
 
 
c32b98e
 
 
 
475d2b0
 
c32b98e
475d2b0
c32b98e
 
6425b43
d84b067
52938ea
6425b43
db9dbb1
 
 
 
 
 
475d2b0
 
6425b43
52938ea
6425b43
52938ea
 
4213e37
 
6425b43
 
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
# Use an official Python runtime as a parent image
FROM python:3.10-slim-bullseye

# Set the working directory in the container to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install system dependencies required for building sqlite3 and other operations
RUN apt-get update && \
    apt-get install -y --no-install-recommends git wget build-essential libsqlite3-dev && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Upgrade to a more recent SQLite version
RUN wget https://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz && \
    tar xvfz sqlite-autoconf-3360000.tar.gz && \
    cd sqlite-autoconf-3360000 && \
    ./configure --prefix=/usr --disable-static CFLAGS="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_FTS3_TOKENIZER=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1" && \
    make && \
    make install && \
    cd .. && \
    rm sqlite-autoconf-3360000.tar.gz && \
    rm -rf sqlite-autoconf-3360000

# Verify sqlite3 version system-wide
RUN sqlite3 --version

# Install Python dependencies
RUN pip install poetry gradio

# Create a non-root user and change ownership of the /app directory
RUN adduser --disabled-password --gecos '' myuser

# Change ownership and permissions before switching to myuser
RUN chown -R myuser:myuser /app && chmod -R 755 /app && \
    mkdir -p /app/.cache && chown myuser:myuser /app/.cache && \
    chmod 777 /tmp

# Switch to the non-root user
USER myuser

# Expose the port Gradio runs on
EXPOSE 7860

RUN chmod +x /app/start.sh

# Run the start script when the container launches
CMD ["/app/start.sh"]