diff --git a/Dockerfile b/Dockerfile index c78dbf1..5c51a51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# adapted from https://dev.to/farcellier/package-a-poetry-project-in-a-docker-container-for-production-3b4m + FROM python:3.12.5-slim-bookworm AS build # Set our workdir @@ -7,9 +9,9 @@ WORKDIR /app RUN pip install --no-cache-dir poetry==1.8.3 # Now copy the app over and build a wheel -COPY src /app/src/ -COPY pyproject.toml /app/ -RUN poetry install +COPY athena_federation /app/athena_federation/ +COPY . /app +RUN poetry install --without dev --no-interaction ## Now use the compiled wheel in our lambda function FROM arm64v8/python:3.12.5-slim-bookworm AS lambda @@ -20,7 +22,7 @@ COPY --from=build /app/dist/athena_federation-*-py3-none-any.whl / RUN pip install --no-cache-dir /athena_federation-*-py3-none-any.whl WORKDIR /app -COPY example/ ./ +ENV PATH="/app/.venv/bin:$PATH" RUN ls ./ -CMD [ "handler.lambda_handler" ] +CMD ["pytest"] diff --git a/Makefile b/Makefile index f147f63..4600e2c 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,10 @@ docker-build: docker build -t athena-federation . docker-debug: - docker build -t athena-federation . --no-cache --build-arg DEBUG=true --build-arg ARCHITECTURE=arm64 + docker build -t athena-federation . --no-cache --build-arg DEBUG=true + +docker-poetry-config: + poetry config virtualenvs.in-project true --local # Run Docker container diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 0000000..ab1033b --- /dev/null +++ b/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true