Skip to content

Commit 4035852

Browse files
committed
[Docker] Migrate aws to python
1 parent e0f5560 commit 4035852

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ COPY --from=base /opt/venv /opt/venv
3030
# Add default config files
3131
COPY octobot/config /octobot/octobot/config
3232

33-
COPY docker/*.sh /octobot/
33+
COPY docker/* /octobot/
3434

3535
# 1. Install requirements
3636
# 2. Add cloudflare gpg key and add cloudflare repo in apt repositories (from https://pkg.cloudflare.com/index.html)
@@ -44,7 +44,7 @@ RUN apt-get update \
4444
&& curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null \
4545
&& echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared buster main' | tee /etc/apt/sources.list.d/cloudflared.list \
4646
&& apt-get update \
47-
&& apt-get install -y --no-install-recommends jq curl cloudflared libxslt-dev libxcb-xinput0 libjpeg62-turbo-dev zlib1g-dev libblas-dev liblapack-dev libatlas-base-dev libopenjp2-7 libtiff-dev \
47+
&& apt-get install -y --no-install-recommends curl cloudflared libxslt-dev libxcb-xinput0 libjpeg62-turbo-dev zlib1g-dev libblas-dev liblapack-dev libatlas-base-dev libopenjp2-7 libtiff-dev \
4848
&& rm -rf /var/lib/apt/lists/* \
4949
&& ln -s /opt/venv/bin/OctoBot OctoBot # Make sure we use the virtualenv \
5050
&& chmod +x docker-entrypoint.sh

docker/aws.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import json
3+
from urllib.request import urlopen
4+
5+
if __name__ == '__main__':
6+
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v4.html
7+
container_metadata_url = os.getenv("ECS_CONTAINER_METADATA_URI_V4", None)
8+
if container_metadata_url is not None:
9+
try:
10+
with urlopen(container_metadata_url + "/taskWithTags") as response:
11+
body = response.read()
12+
container_metadata = json.loads(body)
13+
for key, value in container_metadata['TaskTags'].items():
14+
os.environ[key] = value
15+
except Exception as e:
16+
print("Error when requesting or parsing aws metadata")

docker/aws.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

docker/docker-entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ if [[ -n "${OCTOBOT_CONFIG}" ]]; then
55
echo "$OCTOBOT_CONFIG" | tee /octobot/user/config.json >/dev/null
66
fi
77

8-
bash aws.sh
8+
python aws.py
9+
910
bash tunnel.sh
1011

1112
./OctoBot

docker/util.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)