Skip to content

Commit

Permalink
Use pinned dependencies also when building lambda function
Browse files Browse the repository at this point in the history
  • Loading branch information
Rikuoja committed Jan 26, 2024
1 parent acb0c30 commit 9c73933
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rebuild:
build-lambda:
docker-compose -f docker-compose.dev.yml build db_manager
docker-compose -f docker-compose.dev.yml up -d --no-deps db_manager
cd database; \
for func in db_manager ; do \
rm -rf tmp_lambda; \
echo $$func; \
Expand Down
18 changes: 8 additions & 10 deletions database/db_manager.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
FROM public.ecr.aws/lambda/python:3.12

# Copy function code
COPY db_manager/db_manager.py ${LAMBDA_TASK_ROOT}/db_manager.py
COPY migrations ${LAMBDA_TASK_ROOT}/migrations
COPY alembic.ini ${LAMBDA_TASK_ROOT}/alembic.ini
COPY base.py ${LAMBDA_TASK_ROOT}/base.py
COPY codes.py ${LAMBDA_TASK_ROOT}/codes.py
COPY models.py ${LAMBDA_TASK_ROOT}/models.py
COPY database/db_manager/db_manager.py ${LAMBDA_TASK_ROOT}/db_manager.py
COPY database/migrations ${LAMBDA_TASK_ROOT}/migrations
COPY database/alembic.ini ${LAMBDA_TASK_ROOT}/alembic.ini
COPY database/base.py ${LAMBDA_TASK_ROOT}/base.py
COPY database/codes.py ${LAMBDA_TASK_ROOT}/codes.py
COPY database/models.py ${LAMBDA_TASK_ROOT}/models.py
COPY requirements.txt ${LAMBDA_TASK_ROOT}/requirements.txt

RUN pip3 install \
psycopg2-binary \
alembic \
--target "${LAMBDA_TASK_ROOT}"
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"

CMD [ "db_manager.handler" ]
3 changes: 1 addition & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ services:

db_manager:
build:
context: database
dockerfile: db_manager.Dockerfile
dockerfile: database/db_manager.Dockerfile
env_file:
- .env.dev
environment:
Expand Down

0 comments on commit 9c73933

Please sign in to comment.