Skip to content

Commit

Permalink
Host Backend on AWS (#88)
Browse files Browse the repository at this point in the history
* added workflow to deploy to ecs

* add aws region

* add env

* fix secret variable name

* fix dockerfile path

* make mvn executable

* fix path dockerfile

* fix target path

* fix: cluster same

* login docker seprately

* update aws region

* add new cluster

* fix cluster name

* change cluster name

* fix secrets

* add workflow file

* add env while building

* fix image name

* add image repo URI in secrets

* fix dockerfile path

* add workflow file

* fix CI to run push

* temp: fix to check if deployment works

* add deploy to ec2 back

* fix ECR public login

* fix ECR public URI

* fix ecr login command

* fix login command

* fix dockerfile

* fix docker push command

* fix tag and push

* fix ecr login

* fix aws login

* fix aws region

* fix ecr-public login region

* deploy to ec2

* Update deploy-to-ec2.yml

* check UI is working or not

* fix: broken change

* change the action runner

* change branch for testing.

* instead of script add steps

* update readme and tokens for integration test (#104)

* update readme

* Update README.md

Co-authored-by: Satyam Bajpai <[email protected]>

* Update README.md

Co-authored-by: Satyam Bajpai <[email protected]>

* Update README.md

Co-authored-by: Satyam Bajpai <[email protected]>

* update auth link

* update tokens

* format code

* update public key

* update public key

* update tokens

* fix readme

* Update README.md

Co-authored-by: Akhil Khubchandani <[email protected]>

* address review comments

---------

Co-authored-by: Satyam Bajpai <[email protected]>
Co-authored-by: Akhil Khubchandani <[email protected]>

* (#114)-Downgrading JWT Libraries as short-term fix for Public Key Size limitation issue (#115)

* Adding integration tests for endorsement service (#107)

* Added integration tests for endorsement service

* Added test suite for integration tests

* testing separation of unit and integration ci and pomxml

* Addressed review comments and added build step in CI

* Fix API contract and added pagination assertions to integration tests

* Fixing typos and addressing review comments

* Addressed review comments

* Addressed review comments

* Addressed review comments

---------

Co-authored-by: akhil <[email protected]>

* added implementation for V1 search endorsements based on dummy data

* Enabled Unit and Integration tests, Auth whitelist for /v1/endorsements

* Formatting fixed

* Put dummyData implementation behind dummyData=true feature flag, old flow kept intact, tests updated

* formatting fixed

* pass public key as env variable

* fix: remove extra space

* add api v1 prefix and data source version

* fix: command format

* fix: remove extra env

* fix: change branch name

---------

Co-authored-by: Achintya Chatterjee <[email protected]>
Co-authored-by: Prakash Choudhary <[email protected]>
Co-authored-by: Amit Prakash <[email protected]>
Co-authored-by: Bhavika Tibrewal <[email protected]>
Co-authored-by: Satyam Bajpai <[email protected]>
Co-authored-by: Akhil Khubchandani <[email protected]>
Co-authored-by: Chethan <[email protected]>
Co-authored-by: akhil <[email protected]>
  • Loading branch information
9 people authored May 22, 2024
1 parent 0fb989f commit d4b18a9
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 5 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/deploy-to-ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy to EC2

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR Public
id: login-ecr
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_URI }}

- name: Build Docker image
run: docker build -t skill-tree-backend -f skill-tree/Dockerfile .
- name: Tag Docker image
run: docker tag skill-tree-backend:latest ${{ secrets.AWS_ECR_URI }}/skill-tree-backend:latest

- name: Push Docker image to ECR Public
run: docker push ${{ secrets.AWS_ECR_URI }}/skill-tree-backend:latest

deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ${{ secrets.AWS_EC2_USERNAME }}
key: ${{ secrets.AWS_EC2_SSH_PRIVATE_KEY }}
- name: Pull Image from docker hub
run: docker pull ${{ secrets.AWS_ECR_URI }}/skill-tree-backend:latest
- name: Delete old container
run: docker rm -f skill-tree-backend
- name: Run docker container
run: docker run -d -p 8080:8080 --name skill-tree-backend -e RDS_PUBLIC_KEY=${{secrets.RDS_PUBLIC_KEY}} -e API_V1_PREFIX=/api/v1 ${{ secrets.AWS_ECR_URI }}/skill-tree-backend

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ replay_pid*

*.env

target/
target/
11 changes: 11 additions & 0 deletions skill-tree/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM openjdk:17-jdk as build
WORKDIR /app
COPY skill-tree .
RUN ./mvnw --version
RUN ./mvnw clean install -DskipTests

FROM openjdk:17-jdk
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
30 changes: 26 additions & 4 deletions skill-tree/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ version: "3.7"
services:
db:
image: mysql
# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
# (this is just an example, not intended to be a production configuration)
command: --default-authentication-plugin=mysql_native_password
ports:
- 3306:3306
Expand All @@ -13,9 +11,33 @@ services:
MYSQL_PASSWORD: testpassword
MYSQL_ROOT_PASSWORD: password
volumes:
- ./skilltree-database-script.sql:/docker-entrypoint-initdb.d/skilltree-database-script.sql
- mysql-data:/var/lib/mysql

adminer:
image: adminer
ports:
- 9000:8080
- 9000:8080

spring-boot-app:
build:
context: .
dockerfile: Dockerfile
depends_on:
- db
ports:
- 8080:8080
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/skilltree
SPRING_DATASOURCE_USERNAME: testuser
SPRING_DATASOURCE_PASSWORD: testpassword
SPRING_JPA_HIBERNATE_DDL_AUTO: update
MYSQL_HOST: db
DB_NAME: skilltree
MYSQL_DB_USERNAME: testuser
MYSQL_DB_PASSWORD: testpassword
DB_DDL_POLICY: update
API_V1_PREFIX: /api/v1
SPRING_DATASOURCE_VERSION: 8.1.0

volumes:
mysql-data:

0 comments on commit d4b18a9

Please sign in to comment.