From d09d40ecb64f118f61d79753b592fbf928826953 Mon Sep 17 00:00:00 2001 From: Luis Alvergue Date: Tue, 20 May 2025 18:45:53 +0000 Subject: [PATCH] chore: add AWS dev tools to the dev container download installers directly from AWS to ensure we use the latest version. map host credentials folder to the container. set the default AWS profile to use in the dev container to pems. --- .devcontainer/Dockerfile | 26 ++++++++++++++++++++++++++ .env.sample | 3 +++ compose.yml | 1 + 3 files changed, 30 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 67b85fe..b7f1249 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -10,3 +10,29 @@ RUN pip install --no-cache-dir -r docs/requirements.txt # install streamlit requirements RUN pip install --no-cache-dir -r streamlit_app/requirements.txt + +# install AWS CLI and Copilot CLI (requires root permissions) +USER root +# download AWS CLIs to /tmp to avoid write error (23) from curl command +WORKDIR /tmp +RUN HOST_ARCH=$(uname -m) && \ + case "$HOST_ARCH" in \ + x86_64) HOST_ARCH="amd64" ;; \ + aarch64) HOST_ARCH="arm64" ;; \ + esac \ + && if [ "$HOST_ARCH" = "amd64" ]; then \ + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"; \ + elif [ "$HOST_ARCH" = "arm64" ]; then \ + curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"; \ + fi \ + && unzip awscliv2.zip \ + && ./aws/install \ + && rm -rf aws awscliv2.zip + +RUN curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux \ + && chmod +x copilot \ + && mv copilot /usr/local/bin/copilot + +# Switch back to non-root user and app directory +USER $USER +WORKDIR /$USER/app diff --git a/.env.sample b/.env.sample index 7e2c05e..bf460ce 100644 --- a/.env.sample +++ b/.env.sample @@ -13,3 +13,6 @@ DJANGO_DB_FIXTURES="pems/local_fixtures.json" STREAMLIT_LOCAL_PORT=8501 # options: hidden, sidebar STREAMLIT_NAV=hidden + +# AWS +AWS_PROFILE=pems diff --git a/compose.yml b/compose.yml index ea9309c..5da1c4d 100644 --- a/compose.yml +++ b/compose.yml @@ -20,6 +20,7 @@ services: entrypoint: sleep infinity volumes: - ./:/caltrans/app + - ${HOME}/.aws:/home/caltrans/.aws docs: image: caltrans/pems:dev