-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (23 loc) · 880 Bytes
/
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
ARG FUNCTION_DIR="/function"
FROM python:3.12-slim AS base
ARG FUNCTION_DIR
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.3 /lambda-adapter /opt/extensions/lambda-adapter
COPY --from=ghcr.io/astral-sh/uv:0.3.0 /uv /usr/local/bin/uv
ENV UV_CACHE_DIR=/tmp/uv UV_LINK_MODE=copy
WORKDIR ${FUNCTION_DIR}
FROM base AS builder
COPY src/ ${FUNCTION_DIR}
RUN --mount=type=cache,target=/tmp/uv \
uv sync --no-dev
# Collect all static files
WORKDIR ${FUNCTION_DIR}
ENV DJANGO_SECRET_KEY="dummy-secret-key-for-static-files-collection" ALLOWED_HOSTS=""
RUN uv run ./manage.py collectstatic --noinput --clear
FROM base AS prod
ARG FUNCTION_DIR
# Copy django static files
COPY --from=builder /bundle /bundle
COPY src/ ${FUNCTION_DIR}
COPY --from=builder ${FUNCTION_DIR}/.venv ${FUNCTION_DIR}/.venv
EXPOSE 8080
CMD ["uv", "run", "gunicorn", "config.wsgi:application"]