-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathDockerfile
58 lines (47 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
52
53
54
55
56
57
58
FROM python:3.12-slim-bookworm
ARG LANCEDB_CONFIG_DIR=/var/lib/tracecat/lancedb
# Define the environment variables
ENV API_MODULE=tracecat.api.app:app
ENV HOST=0.0.0.0
ENV PORT=8000
ENV TRACECAT_DIR=/var/lib/tracecat
ENV LANCEDB_CONFIG_DIR=/var/lib/tracecat/lancedb
# Expose the application port
EXPOSE $PORT
# Install necessary packages, including acl
RUN apt-get update && \
apt-get install -y acl && \
rm -rf /var/lib/apt/lists/*
# Copy and run the script to install additional packages
COPY scripts/install-packages.sh .
RUN chmod +x install-packages.sh && \
./install-packages.sh && \
rm install-packages.sh
COPY scripts/auto-update.sh ./auto-update.sh
RUN chmod +x auto-update.sh && \
./auto-update.sh && \
rm auto-update.sh
# Create the apiuser with a specific UID/GID,
# pre-create required directories, and set the correct permissions
RUN groupadd -g 1001 apiuser && \
useradd -m -u 1001 -g apiuser apiuser && \
mkdir -p $TRACECAT_DIR && \
chown -R apiuser:apiuser $TRACECAT_DIR && \
chmod -R 755 $TRACECAT_DIR && \
setfacl -d -m u:apiuser:rwx $TRACECAT_DIR
# Set the working directory inside the container
WORKDIR /app
# Change to the non-root user
USER apiuser
# Copy the application files into the container and set ownership
COPY --chown=apiuser:apiuser ./tracecat /app/tracecat
COPY --chown=apiuser:apiuser ./pyproject.toml /app/pyproject.toml
COPY --chown=apiuser:apiuser ./requirements.txt /app/requirements.txt
COPY --chown=apiuser:apiuser ./README.md /app/README.md
COPY --chown=apiuser:apiuser ./LICENSE /app/LICENSE
# Install package
# Split into multiple layers to cache dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# Command to run the application
CMD ["sh", "-c", "python3 -m uvicorn $API_MODULE --host $HOST --port $PORT --reload"]