Skip to content

Commit

Permalink
configure for aws authentication from docker containers
Browse files Browse the repository at this point in the history
  • Loading branch information
zzeppozz committed Oct 18, 2024
1 parent e2100fe commit 43b4fb2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN venv/bin/pip install debugpy
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
COPY --chown=bison:bison ./aws/ec2/aws_config ./.aws/config
COPY --chown=bison:bison ./config/aws.conf ./.aws/config

CMD tail -f /dev/null
#CMD venv/bin/python -m ${TASK_APP}
Expand Down
4 changes: 2 additions & 2 deletions _sphinx_config/pages/aws/ec2_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SSL certificates
* For testing/development, use self-signed certificates because Cerbot will not create
certificates for an AWS EC2 Public IPv4 DNS, or an IP address.

* Edit the docker-compose.yml file under `nginx` service (which intercepts all web
* Edit the compose.yml file under `nginx` service (which intercepts all web
requests) in `volumes` to bind-mount the directory containing self-signed
certificates to /etc/letsencrypt::

Expand Down Expand Up @@ -131,4 +131,4 @@ https://docs.aws.amazon.com/sdkref/latest/guide/feature-assume-role-credentials.

More info:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
8 changes: 4 additions & 4 deletions _sphinx_config/pages/interaction/debug.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ Docker debugging
Run Docker containers (development)
-------------------------------------------

Note that the development compose file, docker-compose.development.yml, is referenced
Note that the development compose file, compose.development.yml, is referenced
first on the command line. It has elements that override those defined in the
general compose file, docker-compose.yml::
general compose file, compose.yml::

sudo docker compose -f docker-compose.development.yml -f docker-compose.yml up
sudo docker compose -f compose.development.yml -f compose.yml up

Flask has hot-reload enabled.

Expand All @@ -80,7 +80,7 @@ And run this command (which ignores running container)::

Then rebuild/restart::

sudo docker compose -f docker-compose.development.yml -f docker-compose.yml up
sudo docker compose -f compose.development.yml -f compose.yml up

Examine container
-------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions _sphinx_config/pages/interaction/deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Environment status checks:
...
CMD venv/bin/python -m gunicorn -w 4 --bind 0.0.0.0:5000 ${FLASK_APP}

docker-compose.yml::
compose.yml::

services:
bison:
Expand All @@ -66,7 +66,7 @@ Environment status checks:
...
CMD venv/bin/python -m debugpy --listen 0.0.0.0:${DEBUG_PORT} -m ${FLASK_MANAGE} run --host=0.0.0.0

docker-compose.development.yml::
compose.development.yml::

bison:
...
Expand Down Expand Up @@ -114,7 +114,7 @@ script run on instantiation.

* TODO: set up an automated task to download this on creation in S3

* docker-compose.yml bind-mounts this host directory to the /volumes/aws_data
* compose.yml bind-mounts this host directory to the /volumes/aws_data
directory as Read-Only on the backend (bison) container.
* AWS_INPUT_DATA in the .env.conf file points to this volume
* AWS_INPUT_PATH in python code references the AWS_INPUT_DATA environment variable
Expand All @@ -139,7 +139,7 @@ Run the containers (production)

Start the containers with the Docker composition file::

sudo docker compose -f docker-compose.yml up -d
sudo docker compose -f compose.yml up -d

BISON web services are now available at https://bison.spcoco.org/

Expand All @@ -150,11 +150,11 @@ the http/https ports and not allow the docker containers to use them.
Run the containers (development)
-------------------------------------------

Note that the development compose file, docker-compose.development.yml, is referenced
Note that the development compose file, compose.development.yml, is referenced
first on the command line. It has elements that override those defined in the
general compose file, docker-compose.yml::
general compose file, compose.yml::

sudo docker compose -f docker-compose.development.yml -f docker-compose.yml up
sudo docker compose -f compose.development.yml -f compose.yml up

BISON web services are now available at https://localhost/ or
https://bison-dev.spcoco.org/
Expand All @@ -179,7 +179,7 @@ Then rebuild/restart::

sudo docker compose up -d
# or
sudo docker compose -f docker-compose.development.yml -f docker-compose.yml up
sudo docker compose -f compose.development.yml -f compose.yml up

Examine container
-------------------------------------------
Expand Down
21 changes: 2 additions & 19 deletions compose.annotate_riis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,15 @@ services:
context: ./.
target: task
environment:
- TASK_APP=bison.tools.annotate_riis
- TASK_APP=bison.task.annotate_riis
env_file:
./.env.task.conf
restart: unless-stopped
volumes:
# bind mount
# bind mount from host machine
- "/home/ubuntu/aws_data:/volumes/bison_data"
# volumes
- "scratch-path:/scratch-path"
# - "static-files:/home/bison/bison/frontend/static"

# nginx:
# image: nginx:alpine
# restart: unless-stopped
# depends_on:
# bison:
# condition: service_healthy
#
# ports:
# - "80:80"
# volumes:
# - "static-files:/volumes/static-files:ro"
# # bind mounts from host machine
# - "./nginx/nginx.task.conf:/etc/nginx/conf.d/default.conf:ro"
# - "./bison/frontend/static/:/var/www/:ro"

volumes:
scratch-path:
# static-files:
10 changes: 2 additions & 8 deletions compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,5 @@ services:
- DEBUG_PORT=5001
volumes:
- "./flask_app/:/home/bison/flask_app/"

# front-end:
# build:
# context: ./.
# target: base-front-end
# command: ["npm", "run", "watch"]
# volumes:
# - "./bison/frontend/js_src/lib/:/home/node/lib/"
# bind mount from host machine
- "/home/ubuntu/aws_data:/volumes/bison_data"
4 changes: 2 additions & 2 deletions compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ services:
context: ./.
target: task
environment:
- TASK_APP=bison.tools.test_task
- TASK_APP=bison.task.test_task
env_file:
./.env.task.conf
restart: unless-stopped
volumes:
# bind mount
# bind mount from host machine
- "/home/ubuntu/aws_data:/volumes/bison_data"
# volumes
- "scratch-path:/scratch-path"
Expand Down
4 changes: 2 additions & 2 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ services:
./.env.conf
restart: unless-stopped
volumes:
# bind mount from host machine
- "/home/ubuntu/aws_data:/volumes/bison_data"
# volumes
- "scratch-path:/scratch-path"
- "webpack-output:/volumes/webpack-output"
- "static-files:/home/bison/bison/frontend/static"
# bind mounts from host machine
- "./config/aws.conf:/home/bison/.aws/config:ro"

nginx:
image: nginx:alpine
Expand Down
5 changes: 5 additions & 0 deletions config/aws.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[default]
region = us-east-1
output = json
duration_seconds = 43200
credential_source = Ec2InstanceMetadata

0 comments on commit 43b4fb2

Please sign in to comment.