Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker aws #1

Open
wants to merge 66 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
779886d
added workflow to deploy to ecs
MehulKChaudhari Feb 2, 2024
325abfa
add aws region
MehulKChaudhari Feb 2, 2024
0f7782b
add env
MehulKChaudhari Feb 2, 2024
b795805
fix secret variable name
MehulKChaudhari Feb 2, 2024
8752c4c
fix dockerfile path
MehulKChaudhari Feb 2, 2024
52ae9c8
make mvn executable
MehulKChaudhari Feb 2, 2024
ac85ca9
fix path dockerfile
MehulKChaudhari Feb 2, 2024
e30fe91
fix target path
MehulKChaudhari Feb 2, 2024
6f67182
fix: cluster same
MehulKChaudhari Feb 2, 2024
98f93fc
login docker seprately
MehulKChaudhari Feb 2, 2024
63d954d
update aws region
MehulKChaudhari Feb 2, 2024
77a5435
add new cluster
MehulKChaudhari Feb 2, 2024
1109398
fix cluster name
MehulKChaudhari Feb 2, 2024
c621ebc
change cluster name
MehulKChaudhari Feb 3, 2024
b263915
Merge branch 'develop' into docker-aws
Achintya-Chatterjee Feb 4, 2024
9900c91
fix secrets
MehulKChaudhari Feb 5, 2024
71a9455
add workflow file
MehulKChaudhari Mar 1, 2024
9ca2da1
add env while building
MehulKChaudhari Mar 2, 2024
34c6aff
fix image name
MehulKChaudhari Mar 2, 2024
717d8db
add image repo URI in secrets
MehulKChaudhari Mar 2, 2024
ad70634
fix dockerfile path
MehulKChaudhari Mar 2, 2024
4df18cf
add workflow file
MehulKChaudhari Mar 6, 2024
9133cf4
fix CI to run push
MehulKChaudhari Mar 6, 2024
6689fce
temp: fix to check if deployment works
MehulKChaudhari Mar 6, 2024
b2cddab
add deploy to ec2 back
MehulKChaudhari Mar 6, 2024
537d35b
fix ECR public login
MehulKChaudhari Mar 8, 2024
f09b86f
fix ECR public URI
MehulKChaudhari Mar 8, 2024
366c876
fix ecr login command
MehulKChaudhari Mar 8, 2024
9723b9c
fix login command
MehulKChaudhari Mar 9, 2024
c2e6c0b
fix dockerfile
MehulKChaudhari Mar 9, 2024
55a7175
fix docker push command
MehulKChaudhari Mar 10, 2024
1f39992
fix tag and push
MehulKChaudhari Mar 10, 2024
0c801d7
fix ecr login
MehulKChaudhari Mar 10, 2024
980aa1c
fix aws login
MehulKChaudhari Mar 10, 2024
6a88aff
fix aws region
MehulKChaudhari Mar 10, 2024
2b3c307
fix ecr-public login region
MehulKChaudhari Mar 10, 2024
1d3eab4
deploy to ec2
MehulKChaudhari Mar 10, 2024
6157c51
Merge branch 'develop' into docker-aws
MehulKChaudhari Mar 10, 2024
8b00b9b
Update deploy-to-ec2.yml
MehulKChaudhari Mar 10, 2024
6ef32d9
check UI is working or not
MehulKChaudhari Mar 12, 2024
a41b4b5
fix: broken change
MehulKChaudhari Mar 12, 2024
fc73668
Merge branch 'develop' into docker-aws
prakashchoudhary07 Mar 12, 2024
01eb236
Merge branch 'develop' into docker-aws
iamitprakash Mar 17, 2024
224412f
Merge branch 'develop' into docker-aws
MehulKChaudhari Mar 24, 2024
57f1ec9
change the action runner
MehulKChaudhari May 8, 2024
ab161da
change branch for testing.
MehulKChaudhari May 8, 2024
51f7c17
instead of script add steps
MehulKChaudhari May 8, 2024
12662a0
update readme and tokens for integration test (#104)
bhtibrewal Apr 7, 2024
f1b84fc
(#114)-Downgrading JWT Libraries as short-term fix for Public Key Siz…
akhilkh2000 Apr 20, 2024
5c3d653
Adding integration tests for endorsement service (#107)
Chethan64 Apr 21, 2024
cb2d58b
added implementation for V1 search endorsements based on dummy data
akhilkh2000 Mar 19, 2024
82566a8
Enabled Unit and Integration tests, Auth whitelist for /v1/endorsements
akhilkh2000 Apr 21, 2024
053e5bf
Formatting fixed
akhilkh2000 Apr 21, 2024
81e8966
Put dummyData implementation behind dummyData=true feature flag, old …
akhilkh2000 May 2, 2024
af9ed1f
formatting fixed
akhilkh2000 May 2, 2024
93bcc0b
pass public key as env variable
MehulKChaudhari May 10, 2024
e83465b
fix: remove extra space
MehulKChaudhari May 10, 2024
2ec0c36
add api v1 prefix and data source version
MehulKChaudhari May 10, 2024
f7edcae
fix: command format
MehulKChaudhari May 10, 2024
76a16a3
fix: remove extra env
MehulKChaudhari May 10, 2024
08664ab
fix: change branch name
MehulKChaudhari May 10, 2024
29b1de8
Merge branch 'develop' into docker-aws
MehulKChaudhari May 10, 2024
67524a7
feat: create approve/reject endorsement (#116)
Atifsid May 16, 2024
c6f3764
chore: add tests for update endorsement status (#117)
Atifsid May 16, 2024
0fb989f
Update the DB Schema - Remove User Joins (#119)
bhtibrewal May 21, 2024
8d453f4
Merge branch 'develop' into docker-aws
prakashchoudhary07 May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
81 changes: 69 additions & 12 deletions api-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,25 @@ paths:



/endorsements/{endorsementId}:
/endorsements/{id}?status={EndorsementStatus}:
patch:
tags:
- endorsements
parameters:
- name: endorsementId
- name: id
schema:
type: string
format: UUID
in: path
description: EndorsementId which has to be modified
required: true
requestBody:
required: true
content:
application/json:
schema:
type: object
$ref: '#/components/schemas/endorsementUpdate'
- name: status
schema:
type: string,
format: EndorsementStatus,
in: query
description: New endorsement status which has to be updated
required: true
summary: Update endorsement status given endorsementId
description: Update endorsement status given endorsement id, **this can be only used by Super User for now**
operationId: updateEndorsementStatusGivenId
Expand All @@ -256,8 +257,7 @@ paths:
application/json:
schema:
type: object
$ref: '#/components/schemas/endorsementResponse'

$ref: '#/components/schemas/UpdateEndorsementResponse'

'400':
description: Invalid endorsement Id value
Expand All @@ -267,6 +267,30 @@ paths:
type: object
$ref: '#/components/schemas/ApiResponseFailureInvalidParameter'

'400':
description: Invalid endorsement status
content:
application/json:
schema:
type: object
$ref: '#/components/schemas/ApiResponseFailureInvalidParameter'

'409':
description: Updating the status of an endorsement that has been accepted/rejected
content:
application/json:
schema:
type: object
$ref: '#/components/schemas/ApiResponseFailureEndorsementUpdateResponse'

'403':
description: Unauthorized access, user is not a super user
content:
application/json:
schema:
type: object
$ref: '#/components/schemas/ApiResponseFailureUnauthorized'

'503':
description: Service Unavailable
content:
Expand Down Expand Up @@ -580,4 +604,37 @@ components:
ApiResponseForSkillName:
type: array
items:
$ref: '#/components/schemas/skillUsersResponse'
$ref: '#/components/schemas/skillUsersResponse'

UpdateEndorsementResponse:
type: object
properties:
code:
type: integer
format: int32
example: 200
message:
type: string
example: Successfully updated endorsement status

ApiResponseFailureUnauthorized:
type: object
properties:
code:
type: integer
format: int32
example: 403
message:
type: string
example: Unauthorized, Access is only available to super users

ApiResponseFailureEndorsementUpdateResponse:
type: object
properties:
code:
type: integer
format: int32
example: 409
message:
type: string
example: Endorsement is already updated, Cannot modify status
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:
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@ public ResponseEntity<GenericResponse<EndorsementDTO>> postEndorsement(
new GenericResponse<EndorsementDTO>(null, "Failed to create endorsement"),
HttpStatus.BAD_REQUEST);
}

@PatchMapping(value = "/{id}")
public ResponseEntity<GenericResponse<Void>> updateEndorsementStatus(
@PathVariable(value = "id") UUID id, @RequestParam String status) {
return ResponseEntity.ok().body(endorsementService.updateEndorsementStatus(id, status));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Builder
public class EndorsementDRO {
@NotNull(message = "user id cannot be null")
private UUID userId;
private UUID endorseeId;

@NotNull(message = "skill id cannot be null")
private UUID skillId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.RDS.skilltree.EndorsementList.EndorsementListModel;
import com.RDS.skilltree.Skill.SkillDTO;
import com.RDS.skilltree.User.UserDTO;
import com.RDS.skilltree.utils.TrackedProperties;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
Expand All @@ -14,7 +13,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class EndorsementDTO extends TrackedProperties {
private UUID id;
private UserDTO user;
private UUID endorseeId;
private SkillDTO skill;
private EndorsementStatus status;
private List<EndorsementListModel> endorsersList;
Expand All @@ -23,7 +22,7 @@ public static EndorsementDTO toDto(EndorsementModel endorsementModel) {
EndorsementDTO endorsementDTO =
EndorsementDTO.builder()
.id(endorsementModel.getId())
.user(UserDTO.toDTO(endorsementModel.getUser()))
.endorseeId(endorsementModel.getEndorseeId())
.skill(SkillDTO.toDto(endorsementModel.getSkill()))
.status(endorsementModel.getStatus())
.endorsersList(endorsementModel.getEndorsersList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.RDS.skilltree.EndorsementList.EndorsementListModel;
import com.RDS.skilltree.Skill.SkillModel;
import com.RDS.skilltree.User.UserModel;
import com.RDS.skilltree.utils.TrackedProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
Expand All @@ -23,9 +22,8 @@ public class EndorsementModel extends TrackedProperties {
@Column(name = "id", columnDefinition = "BINARY(16)")
private UUID id;

@ManyToOne(targetEntity = UserModel.class, cascade = CascadeType.ALL)
@JoinColumn(name = "user_id", referencedColumnName = "id")
private UserModel user;
@Column(name = "endorsee_id")
private UUID endorseeId;

@ManyToOne(targetEntity = SkillModel.class, cascade = CascadeType.ALL)
@JoinColumn(name = "skill_id", referencedColumnName = "id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Repository
public interface EndorsementRepository extends JpaRepository<EndorsementModel, UUID> {
List<EndorsementModel> findByUserId(UUID userId);
List<EndorsementModel> findByEndorseeId(UUID userId);

List<EndorsementModel> findBySkillId(UUID skillId);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.RDS.skilltree.Endorsement;

import com.RDS.skilltree.Common.Response.GenericResponse;
import java.io.IOException;
import java.util.UUID;
import org.springframework.data.domain.Page;
Expand All @@ -15,4 +16,6 @@ Page<EndorsementModelFromJSON> getEndorsementsFromDummyData(
PageRequest pageRequest, String skillID, String userID) throws IOException;

EndorsementModel createEndorsement(EndorsementDRO endorsementDRO);

GenericResponse<Void> updateEndorsementStatus(UUID id, String status);
}
Loading
Loading