mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Updated lamdba's dockerfile and serverless script to try and build the lambda from the docker image in ecr
This commit is contained in:
parent
9a98503569
commit
f27f6838cc
5 changed files with 30 additions and 38 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
model_data/local_data/*
|
model_data/local_data/*
|
||||||
backend/tests/*
|
backend/tests/*
|
||||||
|
backend/node_modules/*
|
||||||
recommendations/tests/*
|
recommendations/tests/*
|
||||||
model_data/tests/*
|
model_data/tests/*
|
||||||
infrastructure/*
|
infrastructure/*
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,11 @@ part of a larger application
|
||||||
|
|
||||||
# Folders
|
# Folders
|
||||||
|
|
||||||
|
### backend/
|
||||||
|
|
||||||
|
This folder contains the code for the fastapi backend service, which provides an interface to
|
||||||
|
much of the functionality in this repository, for the frontend
|
||||||
|
|
||||||
### model_data/
|
### model_data/
|
||||||
|
|
||||||
This folder contains related to the reading and preparation of
|
This folder contains related to the reading and preparation of
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,26 @@ FastAPI automatically generates interactive API documentation for your applicati
|
||||||
server and visit <yourlocalurl>/docs in your browser. Alternatively, you can go to
|
server and visit <yourlocalurl>/docs in your browser. Alternatively, you can go to
|
||||||
<yourlocalurl>/redoc to view the documentation in the ReDoc format.
|
<yourlocalurl>/redoc to view the documentation in the ReDoc format.
|
||||||
|
|
||||||
|
## Building the backend docker image locally
|
||||||
|
|
||||||
|
To build the backend docker image locally, run the following command from the root of the project directory:
|
||||||
|
|
||||||
|
```commandline
|
||||||
|
docker build -t fastapi-lambda-image:latest -f backend/docker/lambda.Dockerfile .
|
||||||
|
```
|
||||||
|
|
||||||
|
To check the size of the resulting image, run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker images | grep fastapi-lambda-image
|
||||||
|
```
|
||||||
|
|
||||||
|
To run a shell inside the Docker container to inspect its contents, run:
|
||||||
|
|
||||||
|
```commandline
|
||||||
|
docker run -it fastapi-lambda-image:latest /bin/bash
|
||||||
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
To run tests, run the following command from the root of the project directory:
|
To run tests, run the following command from the root of the project directory:
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ RUN apt-get update && apt-get install -y netcat-openbsd
|
||||||
# Install python dependencies
|
# Install python dependencies
|
||||||
COPY ./backend/requirements/base.txt ./backend/requirements/base.txt
|
COPY ./backend/requirements/base.txt ./backend/requirements/base.txt
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip
|
||||||
RUN pip install -r backend/requirements/base.txt
|
# Install and clean up temp caches
|
||||||
|
RUN pip install -r backend/requirements/base.txt && rm -rf /root/.cache
|
||||||
|
|
||||||
# Copy project files
|
# Copy project files
|
||||||
COPY ./backend/ ./backend
|
COPY ./backend/ ./backend
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ service: fastapi-lambda
|
||||||
|
|
||||||
provider:
|
provider:
|
||||||
name: aws
|
name: aws
|
||||||
runtime: python3.10
|
|
||||||
region: eu-west-2
|
region: eu-west-2
|
||||||
architecture: x86_64
|
architecture: x86_64
|
||||||
environment:
|
environment:
|
||||||
|
|
@ -32,46 +31,11 @@ provider:
|
||||||
- arn:aws:s3:::${env:PLAN_TRIGGER_BUCKET}/*
|
- arn:aws:s3:::${env:PLAN_TRIGGER_BUCKET}/*
|
||||||
|
|
||||||
|
|
||||||
package:
|
|
||||||
individually: true
|
|
||||||
patterns:
|
|
||||||
- 'backend/**'
|
|
||||||
- '!backend/tests/**'
|
|
||||||
- 'recommendations/**'
|
|
||||||
- '!recommendations/tests/**'
|
|
||||||
# Exclude all of model_data but then re-include the files we need
|
|
||||||
- '!model_data/**'
|
|
||||||
- 'model_data/BaseUtility.py'
|
|
||||||
- 'model_data/config.py'
|
|
||||||
- 'model_data/optimiser/**'
|
|
||||||
- 'model_data/__init__.py'
|
|
||||||
- 'model_data/EpcClean.py'
|
|
||||||
- 'model_data/utils.py'
|
|
||||||
- 'model_data/epc_attributes/**'
|
|
||||||
- 'datatypes/**'
|
|
||||||
- '!infrastructure/**'
|
|
||||||
- '!data_collection/**'
|
|
||||||
- '!node_modules/**'
|
|
||||||
- '!conservation_areas/**'
|
|
||||||
- '!open_uprn/**'
|
|
||||||
- '!land_registry/**'
|
|
||||||
- '!pytest.ini'
|
|
||||||
- '**/README.md'
|
|
||||||
|
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- serverless-python-requirements
|
- serverless-python-requirements
|
||||||
- serverless-domain-manager
|
- serverless-domain-manager
|
||||||
|
|
||||||
custom:
|
custom:
|
||||||
pythonRequirements:
|
|
||||||
dockerizePip: true
|
|
||||||
dockerFile: backend/docker/lambda.Dockerfile
|
|
||||||
useDocker: true
|
|
||||||
dockerSsh: true
|
|
||||||
fileName: backend/requirements/base.txt
|
|
||||||
dockerBuildCmdExtraArgs:
|
|
||||||
- '--progress=plain'
|
|
||||||
customDomain:
|
customDomain:
|
||||||
domainName: api.${self:provider.environment.DOMAIN_NAME}
|
domainName: api.${self:provider.environment.DOMAIN_NAME}
|
||||||
createRoute53Record: true
|
createRoute53Record: true
|
||||||
|
|
@ -79,7 +43,8 @@ custom:
|
||||||
|
|
||||||
functions:
|
functions:
|
||||||
app:
|
app:
|
||||||
handler: backend.app.main.handler
|
image:
|
||||||
|
uri: ${env:ECR_URI}:latest
|
||||||
events:
|
events:
|
||||||
- http:
|
- http:
|
||||||
path: /{proxy+}
|
path: /{proxy+}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue