Skip to content

Commit

Permalink
Merge pull request #129 from Team-SilverTown/dev
Browse files Browse the repository at this point in the history
🏆 릴리즈 v0.0.1
  • Loading branch information
IjjS authored Mar 15, 2024
2 parents 5cde0d3 + 7c19d12 commit 3fa2f29
Show file tree
Hide file tree
Showing 198 changed files with 12,231 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .aws/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM localstack/localstack:3.2
LABEL authors="ASak1104"

COPY --chown=localstack ./init-aws.sh /etc/localstack/init/ready.d/init-aws.sh
COPY --chown=localstack ./policy.json /etc/localstack/json/policy.json

RUN chmod u+x /etc/localstack/init/ready.d/init-aws.sh
7 changes: 7 additions & 0 deletions .aws/init-aws.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

awslocal s3api create-bucket \
--bucket images
awslocal s3api put-bucket-policy \
--bucket images \
--policy file:///etc/localstack/json/policy.json
90 changes: 90 additions & 0 deletions .aws/masilgasil-ecs-task-prod-revision1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"taskDefinitionArn": "arn:aws:ecs:ap-northeast-2:533267244952:task-definition/masilgasil-ecs-task-prod:1",
"containerDefinitions": [
{
"name": "masilgasil-ecs-container-prod",
"image": "533267244952.dkr.ecr.ap-northeast-2.amazonaws.com/masilgasil-ecr-private:latest",
"cpu": 2048,
"memory": 4096,
"portMappings": [
{
"name": "masilgasil-ecs-container-port",
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"ulimits": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "/ecs/masilgasil-ecs-task-prod",
"awslogs-region": "ap-northeast-2",
"awslogs-stream-prefix": "ecs"
},
"secretOptions": []
},
"systemControls": []
}
],
"family": "masilgasil-ecs-task-prod",
"taskRoleArn": "arn:aws:iam::533267244952:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::533267244952:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"revision": 1,
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "ecs.capability.task-eni"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
}
],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "2048",
"memory": "4096",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"registeredAt": "2024-03-14T17:22:03.151Z",
"registeredBy": "arn:aws:iam::533267244952:user/team-01",
"tags": []
}
89 changes: 89 additions & 0 deletions .aws/masilgasil-ecs-task-revision1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"taskDefinitionArn": "arn:aws:ecs:ap-northeast-2:533267244952:task-definition/masilgasil-ecs-task:1",
"containerDefinitions": [
{
"name": "masilgasil-ecs-container",
"image": "533267244952.dkr.ecr.ap-northeast-2.amazonaws.com/masilgasil-ecr-private:latest",
"cpu": 0,
"portMappings": [
{
"name": "masilgasil-ecs-container-port",
"containerPort": 8080,
"hostPort": 8080,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"ulimits": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "/ecs/masilgasil-ecs-task",
"awslogs-region": "ap-northeast-2",
"awslogs-stream-prefix": "ecs"
},
"secretOptions": []
},
"systemControls": []
}
],
"family": "masilgasil-ecs-task",
"taskRoleArn": "arn:aws:iam::533267244952:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::533267244952:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"revision": 1,
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "ecs.capability.task-eni"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
}
],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "1024",
"memory": "3072",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"registeredAt": "2024-03-04T12:31:29.939Z",
"registeredBy": "arn:aws:iam::533267244952:user/team-01",
"tags": []
}
16 changes: 16 additions & 0 deletions .aws/policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::images/*"
]
}
]
}
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @ASak1104 @shoeone96 and @IjjS will be requested for
# review when someone opens a pull request.
* @Team-SilverTown/Backend
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/⚙-refactoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: "⚙️ Refactoring"
about: Refacoring 내용을 입력해주세요.
title: "⚙️ Refactoring"
labels: ⚙️ Refactoring
assignees: ''

---

# Issue: ⚙️ Refactoring

## Description

<!--수정이 필요한 내용-->

## To do

<!--수정될 내용-->

- [ ] todo

## ETC

<!--기타사항-->
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/✅-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: "✅ Feature"
about: Feature 요구 사항을 입력해주세요.
title: "✅ Feature"
labels: ✅ Feature
assignees: ''

---

# Issue: ✅ Feature

## Description

<!--필요한 기능-->

## To do

<!--추가될 내용-->

- [ ] todo

## ETC

<!--기타사항-->
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## 🎫 관련 이슈

<!--이슈 태스크를 모두 완료하고 닫는다면 * Resolves #번호-->
<!--이슈 태스크를 모두 완료하지는 못 했지만 닫는다면 * Closes #번호-->
<!--열어둔다면 * #번호-->

## 🚀 주요 변경사항

<!--빠른 리뷰를 위해 이해를 도울 만한 설명을..-->

## 💡 기타사항

<!-- ex) 질문. 이후에 이런걸 할거고 또한 지금은 이러한 이유 때문에 이런걸 작업했다. 의존성, 추후해야할 일 등등-->
102 changes: 102 additions & 0 deletions .github/workflows/cd-pipeline-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Deploy dev API to Amazon ECS

on:
push:
branches: [ "dev" ]

permissions:
contents: read

env:
AWS_REGION: ap-northeast-2
SERVER_PORT: 8080

jobs:
job:
name: Deploy dev API
runs-on: ubuntu-latest
environment: dev
steps:
- name: 체크 아웃
uses: actions/checkout@v3

- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'

- name: AWS credentials 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Redis 실행
uses: supercharge/[email protected]
with:
redis-version: 7.2.4-alpine
redis-port: 6379

- name: application.yml 오버라이드
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application.yml
env:
server.port: ${{ env.SERVER_PORT }}
cors.service-origin: ${{ secrets.SERVICE_ORIGIN }}

spring.datasource.username: ${{ secrets.MYSQL_USERNAME }}
spring.datasource.password: ${{ secrets.MYSQL_PASSWORD }}
spring.datasource.url: ${{ secrets.MYSQL_URL }}

spring.data.redis.host: ${{ secrets.REDIS_HOST }}
spring.data.redis.port: ${{ secrets.REDIS_PORT }}

spring.cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY_ID }}
spring.cloud.aws.credentials.secretKey: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
spring.cloud.aws.region.static: ${{ env.AWS_REGION }}
spring.cloud.aws.s3.bucket: ${{ secrets.AWS_S3_IMAGE_BUCKET }}
spring.cloud.aws.s3.endpoint: ${{ secrets.AWS_S3_IMAGE_ENDPOINT }}

jwt.issuer: ${{ secrets.TOKEN_ISSUER }}
jwt.base64-secret: ${{ secrets.TOKEN_SECRET }}
jwt.token-validity-in-seconds: ${{ secrets.TOKEN_EXPIRATION }}

- name: 프로젝트 빌드
uses: gradle/[email protected]
with:
arguments: clean build

- name: Amazon ECR 로그인
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: docker 이미지 업로드
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
PROFILE: ${{ vars.SPRING_ACTIVE_PROFILE }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg PROFILE=$PROFILE .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Amazon ECS task definition 이미지 설정
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ vars.ECS_TASK_DEFINITION }}
container-name: ${{ vars.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Amazon ECS task definition 배포
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ vars.ECS_SERVICE }}
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
Loading

0 comments on commit 3fa2f29

Please sign in to comment.