Skip to content

Commit bfe84af

Browse files
authored
feat: add Dockerfile and buildspec for offchain price pusher (#264)
1 parent ead15be commit bfe84af

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM python:3.12-slim AS base
2+
3+
ENV PYTHONUNBUFFERED=1 \
4+
PYTHONDONTWRITEBYTECODE=1 \
5+
PIP_NO_CACHE_DIR=off \
6+
PIP_DISABLE_PIP_VERSION_CHECK=on \
7+
PIP_DEFAULT_TIMEOUT=100
8+
9+
ENV PATH="/root/.local/bin:${PATH}"
10+
11+
FROM base as builder
12+
13+
RUN apt-get update &&
14+
apt-get install --no-install-recommends -y \
15+
gcc \
16+
libgmp3-dev \
17+
pipx
18+
19+
RUN pipx install uv
20+
COPY pragma-sdk/ /opt/pragma-sdk/
21+
COPY pragma-utils/ /opt/pragma-utils/
22+
COPY price-pusher/ /opt/price-pusher/
23+
WORKDIR /opt/price-pusher
24+
RUN uv sync --all-extras
25+
26+
FROM base as final
27+
COPY --from=builder /opt /opt
28+
COPY infra/price-pusher/config/ /opt/price-pusher/config/
29+
WORKDIR /opt/price-pusher
30+
ENTRYPOINT /opt/price-pusher/.venv/bin/python3.12 price_pusher/main.py -c ${CONFIG_PATH} -t ${TARGET} -n ${NETWORK} -p ${PRIVATE_KEY} --publisher-name ${PUBLISHER_NAME} --publisher-address ${PUBLISHER_ADDRESS} --api-key ${API_KEY} --api-base-url ${API_BASE_URL}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 0.2
2+
phases:
3+
pre_build:
4+
commands:
5+
- echo Logging in to Amazon ECR...
6+
- aws --version
7+
- aws ecr get-login-password --region $ECR_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com
8+
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/$ECR_REPOSITORY_NAME
9+
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
10+
- IMAGE_TAG=${COMMIT_HASH:=latest}
11+
build:
12+
commands:
13+
- echo Build started on `date`
14+
- echo Building the Docker image...
15+
- ls -ltr
16+
- docker build -f infra/price-pusher/offchain/Dockerfile -t $REPOSITORY_URI:latest .
17+
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
18+
post_build:
19+
commands:
20+
- echo Build completed on `date`
21+
- echo Pushing the Docker images...
22+
- docker push $REPOSITORY_URI:latest
23+
- docker push $REPOSITORY_URI:$IMAGE_TAG
24+
- echo Writing image definitions file...
25+
- printf '[{"name":"%s","imageUri":"%s"}]' $ECS_CONTAINER_NAME $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
26+
artifacts:
27+
files:
28+
- imagedefinitions.json
29+
- infra/price-pusher/offchain/config.yml
30+
discard-paths: yes
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
path: "/"
2+
container_port: 8080
3+
health_check_path: "/"
4+
container_environment:
5+
- region: "eu-west-3"
6+
- prefix: "/conf/{{ SERVICE_NAME }}/{{ RUN_ENV }}"
7+
- keys:
8+
- CONFIG_PATH
9+
- TARGET
10+
- NETWORK
11+
- PRIVATE_KEY
12+
- PUBLISHER_NAME
13+
- PUBLISHER_ADDRESS
14+
- API_KEY
15+
- API_BASE_URL

0 commit comments

Comments
 (0)