-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
63 lines (37 loc) · 1.32 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
59
60
61
62
63
# syntax=docker/dockerfile:1
FROM python:3.9-slim AS base
WORKDIR /app
# To install poetry, pyurl (for Amazon SQS conncection), and git (for cloning and blaming repos)
RUN apt-get update && \
apt-get install -y curl gcc libcurl4-openssl-dev libssl-dev git
# To print directly to stdout instead of buffering output
ENV PYTHONUNBUFFERED=true
# Upgrade pip and install Poetry
RUN python -m pip install --upgrade pip && \
curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Copy poetry.lock* in case it doesn't exist in the repo
COPY pyproject.toml poetry.lock* ./
RUN poetry install --no-root
# ==================== production ====================
FROM base AS production
# To install psycopg2 (for PostgreSQL connection)
RUN apt-get update && \
apt-get install -y libpq-dev
RUN poetry install --no-root --with prod
COPY . .
EXPOSE 8000
CMD ["inv", "api.run.prod"]
# ==================== debug ====================
FROM base AS debug
RUN poetry install --no-root --with dev
COPY . .
EXPOSE 8000
CMD ["inv", "api.run.dev", "-h", "0.0.0.0"]
# ==================== test ====================
FROM base AS test
RUN poetry install --no-root --with test
COPY . .
CMD ["inv", "test"]