-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (38 loc) · 1.1 KB
/
Dockerfile
File metadata and controls
50 lines (38 loc) · 1.1 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
FROM python:3.10
# Setting environment variables for Python
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=off
ENV ALEMBIC_CONFIG=/usr/src/alembic/alembic.ini
# Installing dependencies
RUN apt update && apt install -y \
gcc \
libpq-dev \
netcat-openbsd \
postgresql-client \
dos2unix \
&& apt clean
# Install Poetry
RUN python -m pip install --upgrade pip && \
pip install poetry
# Copy dependency files
COPY ./poetry.lock /usr/src/poetry/poetry.lock
COPY ./pyproject.toml /usr/src/poetry/pyproject.toml
COPY ./alembic.ini /usr/src/alembic/alembic.ini
# Configure Poetry to avoid creating a virtual environment
RUN poetry config virtualenvs.create false
# Selecting a working directory
WORKDIR /usr/src/poetry
# Install dependencies with Poetry
RUN poetry lock
RUN poetry install --no-root
# Selecting a working directory
WORKDIR /usr/src/fastapi
# Copy the source code
COPY ./src .
# Copy commands
COPY ./commands /commands
# Ensure Unix-style line endings for scripts
RUN dos2unix /commands/*.sh
# Add execute bit to commands files
RUN chmod +x /commands/*.sh