From cf4b61e20d50c202ccd97e1d6340b09d45525c51 Mon Sep 17 00:00:00 2001 From: sonyasha Date: Sun, 16 Mar 2025 21:06:28 -0700 Subject: [PATCH 1/2] Update docker setup, add env file example --- .dockerignore | 2 -- Dockerfile | 16 ++++++++++++++++ docker-compose.yml | 5 ++--- env.example | 7 +++++++ 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 env.example diff --git a/.dockerignore b/.dockerignore index 1f2644c..bc5483e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,6 @@ __pycache__/ .git/ -.serverless/ .gitignore -serverless.yml *.env diff --git a/Dockerfile b/Dockerfile index fabb2a2..b64e7b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,25 @@ FROM python:3.13-alpine WORKDIR /app +RUN apk add --no-cache \ + nodejs \ + npm \ + bash + COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r requirements.txt +# Copy Serverless config before installing plugins +COPY serverless.yml /app/serverless.yml + +# Install Serverless Framework globally +RUN npm install -g serverless + +# Install Serverless plugins +RUN serverless plugin install -n serverless-wsgi && \ + serverless plugin install -n serverless-ssm-fetch && \ + serverless plugin install -n serverless-python-requirements + COPY . /app EXPOSE 5000 diff --git a/docker-compose.yml b/docker-compose.yml index fbc6a17..f914c99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,5 @@ services: - ./api:/app/api ports: - "${PORT}:${PORT}" - environment: - - API_KEY=${API_KEY} - - FLASK_DEBUG=1 \ No newline at end of file + env_file: + - .env \ No newline at end of file diff --git a/env.example b/env.example new file mode 100644 index 0000000..2e85255 --- /dev/null +++ b/env.example @@ -0,0 +1,7 @@ +AWS_REGION=your-aws-region +AWS_ACCESS_KEY_ID=your-access-key +AWS_SECRET_ACCESS_KEY=your-secret-key +SERVERLESS_ACCESS_KEY=your-serverless-key +API_KEY=any-key +PORT=local-port-eg-5000 +FLASK_DEBUG=1 \ No newline at end of file From e388c2ab1a9db79b41b23a64b59bb73d9fca9d16 Mon Sep 17 00:00:00 2001 From: sonyasha Date: Sun, 16 Mar 2025 21:13:15 -0700 Subject: [PATCH 2/2] Explicitly set variables in docker-compose --- docker-compose.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f914c99..8d03dec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,5 +6,11 @@ services: - ./api:/app/api ports: - "${PORT}:${PORT}" - env_file: - - .env \ No newline at end of file + environment: + - API_KEY=${API_KEY} + - FLASK_DEBUG=1 + - AWS_REGION=${AWS_REGION} + - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} + - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} + - SERVERLESS_ACCESS_KEY=${SERVERLESS_ACCESS_KEY} + - PORT=${PORT} \ No newline at end of file