Skip to content

Commit

Permalink
run minimal dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Aug 17, 2024
1 parent c769248 commit cdcb2a1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
22 changes: 3 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,11 @@

FROM python:3.12.5-slim-bookworm AS build

# Set our workdir
WORKDIR /app

# Get ready to build
RUN pip install --no-cache-dir poetry==1.8.3

# Now copy the app over and build a wheel
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
COPY . .

ENV TARGET_BUCKET=replace_me

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
ENV PATH="/app/.venv/bin:$PATH"
RUN ls -R ./
RUN poetry install --without dev --no-interaction

# CMD [ "tests.handler.lambda_handler" ]
ENTRYPOINT ["poetry", "run", "python", "-m", "athena_federation.main"]
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ docker-status:
# Build Docker image
docker-build:
docker build -t $(PROJ) .
docker images | grep $(PROJ)

docker-debug:
docker build -t $(PROJ) . --no-cache --build-arg DEBUG=true
Expand All @@ -60,7 +61,7 @@ docker-poetry-config:

# Run Docker container

docker-run: docker-build
docker-run:
docker run -it -p $(PORT):$(PORT) $(PROJ)

# Run Docker container in detached mode
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ make watch
make publish
```

## Testing Docker Container Locally
## Testing Connector Locally Using Docker

**WARNING: This currently only works on ARM64 machines.**

You can test your Lambda function locally using Lambda Docker images.
Note that you must have the Docker daemon running on your machine.
Note that you must have a Docker daemon running on your machine.
You can test it by calling the CLI:

### Verifying Docker is running
Expand All @@ -67,7 +69,7 @@ docker ps

### Logging in to Docker

You will need an account on, e.g., https://hub.docker.com.
You will need an account on, e.g., [Docker Hub](https://hub.docker.com).

```shell
sudo docker login
Expand Down
14 changes: 14 additions & 0 deletions athena_federation/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python

import os
import sys


def main():
print("Hello from athena_federation!")
print("Arguments: ", sys.argv)
print("Environment: ", os.environ["VIRTUAL_ENV"])


if __name__ == "__main__":
main()

0 comments on commit cdcb2a1

Please sign in to comment.