forked from keatontaylor/alexa-actions
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
223 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'README.md' | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-west-1 | ||
- | ||
name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
- | ||
name: Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ha-custom-lambda-tailscale | ||
IMAGE_TAG: latest | ||
run: | | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
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,40 @@ | ||
FROM python:3.12 as builder | ||
|
||
WORKDIR /app | ||
COPY ./lambda/config.py . | ||
COPY ./lambda/const.py . | ||
COPY ./lambda/schemas.py . | ||
COPY ./lambda/language_strings.json . | ||
COPY ./lambda/prompts.py . | ||
COPY ./lambda/requirements.txt . | ||
COPY ./lambda/lambda_function.py . | ||
|
||
RUN pip install -t . -r requirements.txt | ||
|
||
FROM alpine:latest as tailscale | ||
WORKDIR /app | ||
COPY . ./ | ||
ENV TSFILE=tailscale_1.64.0_amd64.tgz | ||
RUN wget https://pkgs.tailscale.com/stable/${TSFILE} && \ | ||
tar xzf ${TSFILE} --strip-components=1 | ||
COPY . ./ | ||
|
||
|
||
FROM public.ecr.aws/lambda/python:3.12 | ||
#can't test locally without it | ||
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/local/bin/aws-lambda-rie | ||
RUN chmod 755 /usr/local/bin/aws-lambda-rie | ||
|
||
COPY ./custom_entrypoint /var/runtime/custom_entrypoint | ||
COPY --from=builder /app/ /var/task | ||
COPY --from=tailscale /app/tailscaled /var/runtime/tailscaled | ||
COPY --from=tailscale /app/tailscale /var/runtime/tailscale | ||
RUN mkdir -p /var/run && ln -s /tmp/tailscale /var/run/tailscale && \ | ||
mkdir -p /var/cache && ln -s /tmp/tailscale /var/cache/tailscale && \ | ||
mkdir -p /var/lib && ln -s /tmp/tailscale /var/lib/tailscale && \ | ||
mkdir -p /var/task && ln -s /tmp/tailscale /var/task/tailscale | ||
|
||
# Run on container startup. | ||
EXPOSE 8080 | ||
ENTRYPOINT ["/var/runtime/custom_entrypoint"] | ||
CMD [ "lambda_function.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
if [ "${START_TAILSCALE}" = false ]; then | ||
echo No Tailscale start, because local startup | ||
else | ||
echo Tailscale start | ||
mkdir -p /tmp/tailscale | ||
/var/runtime/tailscaled --tun=userspace-networking --socks5-server=localhost:1055 & | ||
until /var/runtime/tailscale up --authkey=${TAILSCALE_AUTHKEY} --hostname=aws-lambda-app | ||
do | ||
sleep 0.1 | ||
done | ||
echo Tailscale started | ||
fi | ||
|
||
|
||
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then | ||
echo Start aws-lambda-rie awslambdaric | ||
exec env ALL_PROXY="socks5://localhost:1055/" /usr/local/bin/aws-lambda-rie /var/lang/bin/python3.12 -m awslambdaric $@ | ||
else | ||
echo Start python awslambdaric | ||
exec env ALL_PROXY="socks5://localhost:1055/" /var/lang/bin/python3.12 -m awslambdaric $@ | ||
fi |
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,22 @@ | ||
# Built-In Imports | ||
import os | ||
|
||
# Local Imports | ||
from const import ( | ||
HA_URL, | ||
HA_TOKEN, | ||
SSL_VERIFY, | ||
DEBUG, | ||
AWS_DEFAULT_REGION, | ||
ALL_PROXY | ||
) | ||
|
||
|
||
configuration = { | ||
HA_URL: os.environ[HA_URL], | ||
HA_TOKEN: os.environ.get(HA_TOKEN, default=""), | ||
SSL_VERIFY: os.environ.get(SSL_VERIFY, default=False), | ||
DEBUG: os.environ.get(DEBUG, default=False), | ||
AWS_DEFAULT_REGION: os.environ.get(AWS_DEFAULT_REGION), | ||
ALL_PROXY: os.environ.get(ALL_PROXY, default=None) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
isodate~=0.6.0 | ||
pydantic~=1.10.4 | ||
typing-extensions~=4.10.0 | ||
ask-sdk~=1.19.0 | ||
isodate | ||
pydantic | ||
typing-extensions | ||
urllib3 | ||
urllib3[socks] | ||
pysocks | ||
ask_sdk_core | ||
ask_sdk_model | ||
awslambdaric |
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