-
Notifications
You must be signed in to change notification settings - Fork 58
[김창우] sprint8 #391
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
The head ref may contain hidden characters: "part3-\uAE40\uCC3D\uC6B0-spirnt8"
[김창우] sprint8 #391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
창우님 고생하셨습니다!
CI/CD 전반적으로 잘해주셔서 크게 고쳐야 될건 없다고 생각해요.
피드백 드린 부분도 사실 정보성 리뷰라 과제 채점에 큰 영향을 주진 않았어요ㅎㅎ
과제 양이 많았는데 요구사항 대부분 다 지켜주셨네요👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.gitignore에 .idea가 있는데도 불구하고 제외가 안되나 보네요!
아래 글 보시겠어요?
https://coding-groot.tistory.com/59
# 필요한 거 먼저 복사 | ||
COPY build.gradle settings.gradle gradlew /app/ | ||
COPY gradle /app/gradle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dockerfile을 작성할 땐 잘 안 바뀌는 파일을 먼저 COPY 해주시는게 좋습니다.
build.gradle, settings.gradle, gradlew, gradle
위 4개 파일을 잘 안 바뀔거 같은 순서대로 나열해보세요ㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이미지 레이어에 대해선 아래 도커 공식문서 글 보시면 좋습니다!
https://docs.docker.com/get-started/docker-concepts/building-images/understanding-image-layers/
# 의존성 미리 다운(캐시) | ||
RUN chmod +x gradlew && ./gradlew dependencies --no-daemon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gradlew는 내부적으로 gradle을 다운로드 합니다.
builder 스테이지의 베이스 이미지가 gradle:8.10-jdk17-alpine 네요.
두 가지중 하나를 선택하는게 어떨까요?
- 베이스 이미지 gradle
- 베이스 이미지 amazoncorretto + gradlew
# 전체 프로젝트 복사 (.dockerignore로 불필요 파일 제외) | ||
COPY . /app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 전체 프로젝트 복사 (.dockerignore로 불필요 파일 제외) | |
COPY . /app | |
# 전체 프로젝트 복사 (.dockerignore로 불필요 파일 제외) | |
COPY . . |
WORKDIR /app 으로 설정해두셨기 때문에 경로 지정을 하지 않아도 되겠네요ㅎㅎ
# jar 파일 실행 (환경변수 활용) | ||
CMD ["sh", "-c", "java $JVM_OPTS -Dspring.profiles.active=$SPRING_PROFILES_ACTIVE -jar /app/app.jar"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 실행한다면 1번 프로세스가 쉘이 되겠네요.
컨테이너가 종료될 때 1번 프로세스에 종료 시그널이 전달됩니다.
자바 어플리케이션에 종료 시그널이 전달 되지 않으면 graceful shutdown 을 하기가 어려워요.
정말 중요한 내용이라 아래 글을 번역해서라도 읽어보셨으면 좋겠습니다.
https://engineering.pipefy.com/2021/07/30/1-docker-bits-shell-vs-exec/
@Slf4j | ||
@Configuration | ||
public class StorageConfig { | ||
|
||
@Bean | ||
@ConditionalOnProperty(name = "discodeit.storage.type", havingValue = "S3") | ||
public S3Client s3Client( | ||
@Value("${discodeit.storage.s3.access-key}") String accessKey, | ||
@Value("${discodeit.storage.s3.secret-key}") String secretKey, | ||
@Value("${discodeit.storage.s3.region}") String region | ||
) { | ||
return S3Client.builder() | ||
.region(Region.of(region)) | ||
.credentialsProvider(StaticCredentialsProvider.create( | ||
AwsBasicCredentials.create(accessKey, secretKey) | ||
)).build(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnProperty(name = "discodeit.storage.type", havingValue = "s3") | ||
public S3Presigner s3Presigner( | ||
@Value("${discodeit.storage.s3.access-key}") String accessKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Slf4j | |
@Configuration | |
public class StorageConfig { | |
@Bean | |
@ConditionalOnProperty(name = "discodeit.storage.type", havingValue = "S3") | |
public S3Client s3Client( | |
@Value("${discodeit.storage.s3.access-key}") String accessKey, | |
@Value("${discodeit.storage.s3.secret-key}") String secretKey, | |
@Value("${discodeit.storage.s3.region}") String region | |
) { | |
return S3Client.builder() | |
.region(Region.of(region)) | |
.credentialsProvider(StaticCredentialsProvider.create( | |
AwsBasicCredentials.create(accessKey, secretKey) | |
)).build(); | |
} | |
@Bean | |
@ConditionalOnProperty(name = "discodeit.storage.type", havingValue = "s3") | |
public S3Presigner s3Presigner( | |
@Value("${discodeit.storage.s3.access-key}") String accessKey, | |
@Slf4j | |
@Configuration | |
@ConditionalOnProperty(name = "discodeit.storage.type", havingValue = "local", matchIfMissing = true) | |
public class StorageConfig { | |
@Bean | |
public S3Client s3Client( | |
@Value("${discodeit.storage.s3.access-key}") String accessKey, | |
@Value("${discodeit.storage.s3.secret-key}") String secretKey, | |
@Value("${discodeit.storage.s3.region}") String region | |
) { | |
return S3Client.builder() | |
.region(Region.of(region)) | |
.credentialsProvider(StaticCredentialsProvider.create( | |
AwsBasicCredentials.create(accessKey, secretKey) | |
)).build(); | |
} | |
@Bean | |
public S3Presigner s3Presigner( | |
@Value("${discodeit.storage.s3.access-key}") String accessKey, |
이건 어때요?
type: ${STORAGE_TYPE:local} | ||
local: | ||
root-path: /path/to/storage | ||
root-path: ${STORAGE_LOCAL_ROOT_PATH:.discodeit/storage} | ||
s3: | ||
access-key: ${AWS_S3_ACCESS_KEY} | ||
secret-key: ${AWS_S3_SECRET_KEY} | ||
region: ${AWS_S3_REGION} | ||
bucket: ${AWS_S3_BUCKET} | ||
presigned-url-expiration: ${AWS_S3_PRESIGNED_URL_EXPIRATION:600} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spring boot에서는 환경변수를 properties로 바꿔주는 기능을 제공해요!
DISCODEIT_STORAGE_S3_ACCESSKEY -> discodeit.storage.s3.access-key
datasource: | ||
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME} | ||
username: ${DB_USER} | ||
password: ${DB_PASSWORD} | ||
driver-class-name: org.postgresql.Driver | ||
hikari: | ||
maximum-pool-size: 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datasource: | |
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME} | |
username: ${DB_USER} | |
password: ${DB_PASSWORD} | |
driver-class-name: org.postgresql.Driver | |
hikari: | |
maximum-pool-size: 20 | |
datasource: | |
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME} | |
username: ${DB_USER} | |
password: ${DB_PASSWORD} | |
driver-class-name: org.postgresql.Driver | |
hikari: | |
maximum-pool-size: 20 |
들여쓰기가 빠져있네요!
요구사항
기본
심화
스크린샷
env 파일
제출용.txt
RDS
ECR
ECS
VPC
IAM
배포
멘토에게