Skip to content

Commit

Permalink
update fe deps, add v1.28.0 (#28)
Browse files Browse the repository at this point in the history
* update deps

* ncu -u

* add devDependencies

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* clean

* add v1.28.0

* add v1272

* fix 1.28 via lambda container img

* clean

* clean

* clean

* clean

* clean

* clean

* clean
  • Loading branch information
ysawa0 authored Nov 25, 2023
1 parent 58e3492 commit 9634f59
Show file tree
Hide file tree
Showing 13 changed files with 18,520 additions and 8,937 deletions.
45 changes: 45 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Define custom function directory
ARG FUNCTION_DIR="/function"

# Use a slim version of Python for building
FROM python:3.11-slim as build-image

# Include global arg in this stage of the build
ARG FUNCTION_DIR

# Copy function code
RUN mkdir -p ${FUNCTION_DIR}
# COPY . ${FUNCTION_DIR}

# Install the function's dependencies, then clean up the cache to reduce size
RUN pip install --target ${FUNCTION_DIR} awslambdaric && \
pip cache purge

# Use Envoy's slim image if available, otherwise, stick with the current image
# FROM envoyproxy/envoy-contrib:v1.28.0-slim as envoy
FROM envoyproxy/envoy-contrib:v1.28.0 as envoy

# Final base image
FROM python:3.11-slim

# Copy Envoy binary
COPY --from=envoy /usr/local/bin/envoy /usr/local/bin/envoy

# Include global arg in this stage of the build
ARG FUNCTION_DIR

# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}

# Copy in the built dependencies from the build image
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}

# Set the entrypoint for the Lambda Runtime Interface Client
ENTRYPOINT ["/usr/local/bin/python", "-m", "awslambdaric"]

# Copy handler function
COPY apig.py ${FUNCTION_DIR}
COPY main.py ${FUNCTION_DIR}

# Set the handler function
CMD ["main.handler"]
9 changes: 0 additions & 9 deletions backend/README.md

This file was deleted.

47 changes: 0 additions & 47 deletions backend/clct.py

This file was deleted.

29 changes: 26 additions & 3 deletions backend/envoycmd.py → backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,34 @@
from apig import apig_event, apig_resp, init_api_event


def lambda_handler(event, context):
def handler(event, context):
# try:
# pprint(os.listdir("/opt"))
# print('lib')
# # pprint(os.listdir("/opt/lib"))
# # print('lib64')
# # pprint(os.listdir("/opt/lib64"))
# except Exception as e:
# print(e)

# rp = subprocess.run(["ldd", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# res = {
# "out": rp.stdout.decode(),
# "err": rp.stderr.decode(),
# "code": rp.returncode,
# }
# pprint(res["out"])
# pprint(res["err"])
event = init_api_event(event)

u = str(uuid.uuid4())
cmd = "/opt/envoy"
cmd1 = "/opt/envoy"
cmd2 = "/usr/local/bin/envoy"
if os.path.isfile(cmd2):
cmd = cmd2
else:
cmd = cmd1

write_to = f"/tmp/{u}/conf.yaml"
read_from = f"/tmp/{u}"
os.makedirs(read_from, exist_ok=True)
Expand All @@ -37,6 +60,6 @@ def lambda_handler(event, context):
with open("tmp/mock.yaml", "r") as f:
e = {"conf": f.read()}
print(json.dumps(e))
x = lambda_handler(apig_event(e), None)
x = handler(apig_event(e), None)
print("=============== done ===================")
pprint(x)
Loading

0 comments on commit 9634f59

Please sign in to comment.