|
1 | | -FROM python:3.12-slim |
| 1 | +FROM python:3.12-slim AS base |
2 | 2 |
|
3 | | -ENV PYTHONUNBUFFERED=1 \ |
| 3 | +ENV PATH="/venv/bin:/opt/poetry/bin:$PATH" \ |
4 | 4 | POETRY_VIRTUALENVS_CREATE=0 \ |
5 | | - VIRTUAL_ENV=/.venv \ |
6 | | - PATH="/.venv/bin:$PATH" \ |
7 | | - DEBIAN_FRONTEND=noninteractive |
| 5 | + PYTHONUNBUFFERED=1 \ |
| 6 | + VIRTUAL_ENV=/venv |
8 | 7 |
|
9 | | -RUN pip install --no-cache-dir --no-cache poetry |
| 8 | +RUN python3 -m venv /opt/poetry && \ |
| 9 | + /opt/poetry/bin/pip3 install --no-cache-dir --no-cache poetry |
10 | 10 |
|
11 | 11 | WORKDIR /app |
12 | | - |
13 | 12 | COPY poetry.lock pyproject.toml ./ |
| 13 | +RUN --mount=type=cache,target=/root/.cache/pypoetry/cache \ |
| 14 | + --mount=type=cache,target=/root/.cache/pypoetry/artifacts \ |
| 15 | + python3 -m venv /venv && \ |
| 16 | + poetry install --no-interaction --compile && \ |
| 17 | + python3 -m compileall stapi_fastapi |
| 18 | +COPY . /app |
14 | 19 |
|
15 | | -RUN python3 -m venv /.venv && poetry install --no-cache --no-interaction --with lambda |
16 | | -RUN apt-get -yq update && apt-get -yq install git && pip install \ |
17 | | - # git+https://github.com/stapi-utils/stat-fastapi-up42.git@main \ |
18 | | - git+https://github.com/stapi-utils/stat-fastapi-blacksky.git@main \ |
19 | | - git+https://github.com/stapi-utils/stat-fastapi-umbra.git@main \ |
20 | | - && rm -rf /var/lib/apt/lists/* |
21 | 20 |
|
22 | | -COPY . /app |
| 21 | +FROM base AS dev |
| 22 | + |
| 23 | +RUN --mount=type=cache,target=/root/.cache/pypoetry/cache \ |
| 24 | + --mount=type=cache,target=/root/.cache/pypoetry/artifacts \ |
| 25 | + poetry install --no-interaction --with dev --compile |
| 26 | + |
| 27 | +ENV HOST=0.0.0.0 |
| 28 | + |
| 29 | +CMD [ "/opt/poetry/bin/poetry", "run", "dev" ] |
| 30 | + |
| 31 | +FROM base AS lambda-builder |
| 32 | + |
| 33 | +RUN --mount=type=cache,target=/root/.cache/pypoetry/cache \ |
| 34 | + --mount=type=cache,target=/root/.cache/pypoetry/artifacts \ |
| 35 | + poetry install --no-interaction --with lambda --compile |
| 36 | + |
| 37 | + |
| 38 | +FROM python:3.12-slim AS lambda |
| 39 | + |
| 40 | +ENV PATH="/venv/bin:$PATH" \ |
| 41 | + PYTHONUNBUFFERED=1 \ |
| 42 | + VIRTUAL_ENV=/venv |
| 43 | + |
| 44 | +WORKDIR /app |
| 45 | +COPY --from=lambda-builder /app /app |
| 46 | +COPY --from=lambda-builder /venv /venv |
23 | 47 |
|
24 | | -RUN poetry run python -c "import compileall; compileall.compile_path(maxlevels=10)" && poetry run python -m compileall stapi_fastapi |
| 48 | +ENTRYPOINT [ "python3", "-m", "awslambdaric" ] |
| 49 | +CMD ["lambda_handler.handler"] |
0 commit comments