-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (41 loc) · 1.51 KB
/
Dockerfile
File metadata and controls
52 lines (41 loc) · 1.51 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
# OntoKit API Dockerfile
FROM python:3.13-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies (including libgit2 for pygit2)
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
libgit2-dev \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user and git repos directory
RUN useradd --create-home --shell /bin/bash ontokit && \
mkdir -p /data/repos && \
chown -R ontokit:ontokit /data/repos
WORKDIR /home/ontokit/app
# Install Python dependencies
COPY pyproject.toml README.md ./
COPY ontokit/version.py ./ontokit/version.py
RUN pip install --upgrade pip && \
pip install .
# Copy application code
COPY --chown=ontokit:ontokit ontokit/ ./ontokit/
# Copy alembic configuration for migrations
COPY --chown=ontokit:ontokit alembic.ini ./
COPY --chown=ontokit:ontokit alembic/ ./alembic/
# Copy entrypoint script (runs migrations before starting the app)
COPY --chown=ontokit:ontokit scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Switch to non-root user
USER ontokit
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Auto-migrate on startup, then run the app
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["uvicorn", "ontokit.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]