Skip to content

Commit

Permalink
feat: cicd workflow (#93)
Browse files Browse the repository at this point in the history
* Added ci

* Added ci

* Add multiport

* rename directory

* rename directory

* modified dockerfile

* modified dockerfile

* Added infisical

* corrected comments

---------

Co-authored-by: devops72-sre <>
  • Loading branch information
devops72-sre authored Nov 5, 2024
1 parent dc98734 commit 880f706
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
43 changes: 43 additions & 0 deletions infra/theoros/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

FROM public.ecr.aws/docker/library/rust:1.81.0-slim-bookworm AS build

ARG PACKAGE_NAME=theoros

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential pkg-config libssl-dev protobuf-compiler curl libprotobuf-dev && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

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

WORKDIR /app

COPY ./rust .

RUN cargo build --release --package ${PACKAGE_NAME}

FROM public.ecr.aws/docker/library/debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev wget ca-certificates && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN groupadd pragma

RUN useradd -g pragma pragma

USER pragma

WORKDIR /home/pragma
EXPOSE 3000
EXPOSE 8080
COPY --from=build /usr/bin/infisical /usr/bin/infisical
COPY infra/theoros/entrypoint.sh /home/pragma/entrypoint.sh
# Copy artifacts from base image
COPY --from=build /app/target/release/theoros /usr/local/bin/

ENTRYPOINT ["/bin/bash","/home/pragma/entrypoint.sh"]
29 changes: 29 additions & 0 deletions infra/theoros/buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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/theoros/Dockerfile -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- 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/theoros/config.yml
discard-paths: yes
9 changes: 9 additions & 0 deletions infra/theoros/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
path: "/"
container_port: 3000,8080
health_check_path: "/health"
container_environment:
- region: "eu-west-3"
- prefix: "/conf/{{ SERVICE_NAME }}/{{ RUN_ENV }}"
- keys:
- INFISICAL_ENV
- INFISICAL_APP_PATH
7 changes: 7 additions & 0 deletions infra/theoros/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/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
wget ${EVM_URL} -O evm_config.yaml
exec theoros ${ARGS}

0 comments on commit 880f706

Please sign in to comment.