Skip to content

Commit

Permalink
feat:added price-pusher service infra for pragma (#210)
Browse files Browse the repository at this point in the history
* feat:added price-pusher service infra for pragma

* fixed error

---------

Co-authored-by: devops72-sre <>
  • Loading branch information
devops72-sre authored Oct 15, 2024
1 parent 8e5f306 commit 4144144
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
41 changes: 41 additions & 0 deletions infra/price-pusher/pragma/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM python:3.12-slim AS base

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.8.3 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1

ENV PATH="/root/.local/bin:${PATH}"

FROM base as builder

RUN apt-get update && \
apt-get install --no-install-recommends -y \
gcc \
libgmp3-dev \
pipx

RUN apt-get update && apt-get install -y bash curl && curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' | bash \
&& apt-get update && apt-get install -y infisical


RUN pipx install poetry
COPY pragma-sdk/ /opt/pragma-sdk/
COPY pragma-utils/ /opt/pragma-utils/
COPY price-pusher/ /opt/price-pusher/
WORKDIR /opt/price-pusher
RUN poetry env use 3.12
RUN poetry install

FROM base as final
COPY --from=builder /usr/bin/infisical /usr/bin/infisical
COPY --from=builder /opt /opt
COPY infra/price-pusher/pragma/entrypoint.sh /opt/price-pusher/
COPY infra/price-pusher/config/ /opt/price-pusher/config/
WORKDIR /opt/price-pusher
ENTRYPOINT ["bash","/opt/price-pusher/entrypoint.sh"]
30 changes: 30 additions & 0 deletions infra/price-pusher/pragma/buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- aws ecr get-login-password --region $ECR_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/$ECR_REPOSITORY_NAME
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- ls -ltr
- docker build -f infra/price-pusher/pragma/Dockerfile -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- printf '[{"name":"%s","imageUri":"%s"}]' $ECS_CONTAINER_NAME $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
files:
- imagedefinitions.json
- infra/price-pusher/pragma/config.yml
discard-paths: yes
9 changes: 9 additions & 0 deletions infra/price-pusher/pragma/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
path: "/"
container_port: 8080
health_check_path: "/"
container_environment:
- region: "eu-west-3"
- prefix: "/conf/{{ SERVICE_NAME }}/{{ RUN_ENV }}"
- keys:
- INFISICAL_ENV
- INFISICAL_APP_PATH
6 changes: 6 additions & 0 deletions infra/price-pusher/pragma/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail
export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=${INFISICAL_CLIENT_ID} --client-secret=${INFISICAL_CLIENT_SECRET} --silent --plain)
infisical export --projectId=${INFISICAL_PROJECT_ID} --env=${INFISICAL_ENV} --path=${INFISICAL_APP_PATH} > .env
source .env
exec /opt/price-pusher/.venv/bin/python3.12 price_pusher/main.py ${ARGS}

0 comments on commit 4144144

Please sign in to comment.