-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1080d6b
commit 8616005
Showing
31 changed files
with
531 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,3 +169,4 @@ cython_debug/ | |
*.tfstate.* | ||
.vscode/launch.json | ||
.vscode/ | ||
/docker/dynamodb/shared-local-instance.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,60 @@ | ||
version: '3.8' | ||
services: | ||
dynamodb-local: | ||
command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data" | ||
image: "amazon/dynamodb-local:latest" | ||
container_name: dynamodb-local | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- "./docker/dynamodb:/home/dynamodblocal/data" | ||
working_dir: /home/dynamodblocal | ||
dynamodb-local: | ||
# Uncomment if data should be persisted between container restarts | ||
# command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data" | ||
# volumes: | ||
# - "./docker/dynamodb:/home/dynamodblocal/data" | ||
command: "-jar DynamoDBLocal.jar -sharedDb -inMemory" | ||
image: "amazon/dynamodb-local:latest" | ||
container_name: dynamodb-local | ||
ports: | ||
- "8000:8000" | ||
working_dir: /home/dynamodblocal | ||
networks: | ||
- hydrocron | ||
hydrocron-table-create: | ||
image: "amazon/aws-cli" | ||
container_name: hydrocron-table-create | ||
entrypoint: /bin/sh -c | ||
command: > | ||
"aws dynamodb create-table | ||
--table-name hydrocron-swot-reach-table | ||
--attribute-definitions AttributeName=reach_id,AttributeType=S AttributeName=range_start_time,AttributeType=S | ||
--key-schema AttributeName=reach_id,KeyType=HASH AttributeName=range_start_time,KeyType=RANGE | ||
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 | ||
--endpoint-url http://host.docker.internal:8000; | ||
aws dynamodb create-table | ||
--table-name hydrocron-swot-node-table | ||
--attribute-definitions AttributeName=reach_id,AttributeType=S AttributeName=range_start_time,AttributeType=S | ||
--key-schema AttributeName=reach_id,KeyType=HASH AttributeName=range_start_time,KeyType=RANGE | ||
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 | ||
--endpoint-url http://host.docker.internal:8000" | ||
depends_on: | ||
- dynamodb-local | ||
networks: | ||
- hydrocron | ||
environment: | ||
HYDROCRON_ENV: LOCAL | ||
HYDROCRON_dynamodb_endpoint_url: http://host.docker.internal:8000 | ||
AWS_ACCESS_KEY_ID: fakeMyKeyId | ||
AWS_SECRET_ACCESS_KEY: fakeSecretAccessKey | ||
AWS_DEFAULT_REGION: us-west-2 | ||
hydrocron-lambda: | ||
image: "hydrocron:latest" | ||
container_name: hydrocron-lambda | ||
ports: | ||
- "9000:8080" | ||
depends_on: | ||
- hydrocron-table-create | ||
networks: | ||
- hydrocron | ||
environment: | ||
HYDROCRON_ENV: LOCAL | ||
HYDROCRON_dynamodb_endpoint_url: http://host.docker.internal:8000 | ||
AWS_ACCESS_KEY_ID: fakeMyKeyId | ||
AWS_SECRET_ACCESS_KEY: fakeSecretAccessKey | ||
AWS_DEFAULT_REGION: us-west-2 | ||
networks: | ||
# The presence of these objects is sufficient to define them | ||
hydrocron: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
FROM node:10 | ||
LABEL org.opencontainers.image.source="https://github.com/podaac/hydrocron-api" | ||
RUN npm install forever -g | ||
# Define global args | ||
ARG FUNCTION_DIR="/function" | ||
|
||
ENV project_dir /project | ||
ENV app_dir ${project_dir}/app | ||
ENV config_dir ${project_dir}/config | ||
FROM public.ecr.aws/lambda/python:3.10 as build_image | ||
# Include global arg in this stage of the build | ||
ARG FUNCTION_DIR | ||
ENV BUILD_DIR=/hydrocron | ||
|
||
RUN mkdir ${project_dir} ${app_dir} ${config_dir} | ||
WORKDIR ${app_dir} | ||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
WORKDIR $BUILD_DIR | ||
COPY ./hydrocron ./hydrocron | ||
|
||
CMD ${app_dir}/docker/docker-start-command | ||
COPY poetry.lock pyproject.toml README.md ./ | ||
RUN ~/.local/bin/poetry lock --no-update | ||
RUN mkdir -p "${FUNCTION_DIR}" && \ | ||
~/.local/bin/poetry install --only main --sync && \ | ||
cp -r $(~/.local/bin/poetry env list --full-path | awk '{print $1}')/lib/python*/site-packages/* ${FUNCTION_DIR} && \ | ||
cp -r ./hydrocron ${FUNCTION_DIR} && \ | ||
touch ${FUNCTION_DIR}/hydrocron/__init__.py | ||
|
||
COPY docker/docker-entrypoint.sh ${FUNCTION_DIR}/bin/docker-entrypoint.sh | ||
RUN chmod 755 ${FUNCTION_DIR}/bin/docker-entrypoint.sh | ||
|
||
FROM public.ecr.aws/lambda/python:3.10 | ||
# Include global arg in this stage of the build | ||
ARG FUNCTION_DIR | ||
WORKDIR ${FUNCTION_DIR} | ||
|
||
COPY --from=build_image ${FUNCTION_DIR} ${LAMBDA_TASK_ROOT} | ||
ENV PATH="${PATH}:${LAMBDA_TASK_ROOT}/bin" | ||
|
||
CMD [ "hydrocron.api.controllers.timeseries.lambda_handler" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if test -f "logging.ini"; then | ||
echo "Applying user-provided logging.ini" | ||
#!/bin/sh | ||
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then | ||
exec aws-lambda-rie /usr/bin/python -m awslambdaric $1 | ||
else | ||
echo "Using default logging.ini included with hydrocron. This can be overridden by mounting a python logging configuration file at $(pwd)/logging.ini" | ||
python - <<'END' | ||
import pkgutil | ||
logging_conf = pkgutil.get_data('hydrocron', 'conf/logging.ini').decode("utf-8") | ||
with open('logging.ini', 'w') as logging_ini: | ||
logging_ini.write(logging_conf) | ||
END | ||
fi | ||
|
||
uvicorn hydrocron.api:app --proxy-headers --host 0.0.0.0 --port 80 --log-config logging.ini | ||
exec /usr/bin/python -m awslambdaric $1 | ||
fi |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
Module for interacting with the hydrocron database | ||
""" | ||
from .schema import HydrocronTable | ||
|
||
__all__ = ['HydrocronTable', ] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.