forked from Mathpix/hiring-challenge-devops-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (31 loc) · 1.03 KB
/
Dockerfile
File metadata and controls
40 lines (31 loc) · 1.03 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
FROM python:3.12-slim
ARG INSTALL_ATLAS="false"
RUN if [ "$INSTALL_ATLAS" = "true" ]; then \
apt-get update && apt-get install -y curl && \
curl -sSf https://atlasgo.sh | sh; \
rm -rf /var/lib/apt/lists/*; \
fi
WORKDIR /code
RUN pip install uv
# Create a non-root user for the application
RUN useradd --create-home application
# Create a directory for the virtual environment and set ownership
RUN mkdir /venv && chown application:application /venv
# Switch to the new user
USER application
WORKDIR /home/application
# Set up the virtual environment
ENV VIRTUAL_ENV=/venv
ENV WORKON_HOME=/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Copy dependency files and install them into the virtual environment
WORKDIR /code
COPY ./pyproject.toml ./uv.lock ./
RUN uv sync --no-cache --active
# Copy the rest of the application code
COPY ./app /code/app
COPY ./cli /code/cli
COPY ./migrations /code/migrations
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]