Skip to content

Commit

Permalink
[fix] 릴리즈 서버 포트 변경 (#374)
Browse files Browse the repository at this point in the history
* #367 feat: localstack 설정 변경

* #367 feat: nginx 컨테이너 설정 로컬에 추가

* #367 feat: 릴리즈 서버 포트 변경
  • Loading branch information
yonghwankim-dev authored Jun 16, 2024
1 parent d1c2386 commit f464c5f
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 95 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM eclipse-temurin:17-alpine
WORKDIR /app
COPY src/main/resources/*.tsv /app/src/main/resources/
COPY src/main/resources/*.csv /app/src/main/resources/
ARG JAR_FILE=./build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Dspring.profiles.active=${PROFILE}","-jar","app.jar"]
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,3 @@ bootJar {
archiveFileName = "fineAnts_app.jar"
copyPrivate
}

31 changes: 31 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
events{
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$request_uri" "$uri"'
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;

upstream docker-app {
server app:8080;
}

server {
listen 80;
server_name localhost;

location / {
proxy_pass http://docker-app;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
2 changes: 1 addition & 1 deletion docker-compose-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
build: .
restart: always
ports:
- "444:444"
- "443:443"
environment:
PROFILE: release
TZ: Asia/Seoul
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ services:
- "6379:6379"
networks:
- spring-net

networks:
spring-net:
driver: bridge
2 changes: 1 addition & 1 deletion secret
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package codesquad.fineants.global.config.aws.s3;
package codesquad.fineants.global.aws.s3.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand All @@ -11,10 +11,12 @@
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;

@Profile(value = {"release", "production"})
@Configuration
public class AwsS3Config {
import lombok.extern.slf4j.Slf4j;

@Profile(value = {"local", "release", "production"})
@Configuration
@Slf4j
public class S3Config {
@Value("${aws.access-key}")
private String accessKey;
@Value("${aws.secret-key}")
Expand All @@ -23,7 +25,7 @@ public class AwsS3Config {
private String region;

@Bean
public AmazonS3 s3Client() {
public AmazonS3 amazonS3() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, accessSecret);
return AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion(region).build();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public CorsConfiguration corsConfiguration() {
"https://accounts.google.com/o/oauth2/v2/auth"));
config.setAllowedMethods(Collections.singletonList("*"));
config.setAllowedHeaders(Collections.singletonList("*"));
;
config.setAllowCredentials(true);
config.setMaxAge(3600L);
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import codesquad.fineants.domain.watchlist.domain.entity.WatchStock;
import codesquad.fineants.global.errors.errorcode.RoleErrorCode;
import codesquad.fineants.global.errors.exception.FineAntsException;
import codesquad.fineants.global.init.S3BucketInitializer;
import codesquad.fineants.global.security.factory.TokenFactory;
import codesquad.fineants.global.security.oauth.dto.Token;
import jakarta.servlet.http.Cookie;
Expand All @@ -52,7 +51,7 @@
@Slf4j
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Import(value = {AmazonS3Config.class, S3BucketInitializer.class})
@Import(value = {AmazonS3Config.class})
@AutoConfigureWebTestClient
@Testcontainers
@WithMockUser(username = "dragonbead95@naver.com", roles = {"USER"})
Expand Down
35 changes: 34 additions & 1 deletion src/test/java/codesquad/fineants/AmazonS3Config.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
package codesquad.fineants;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.ClassPathResource;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.PutObjectRequest;

import lombok.extern.slf4j.Slf4j;

@Profile("test")
@Configuration(proxyBeanMethods = false)
@Slf4j
public class AmazonS3Config {

@Value("${aws.s3.dividend-bucket}")
private String bucketName;

@Bean
public AmazonS3 amazonS3() {
return AmazonS3ClientBuilder.standard()
AmazonS3 amazonS3 = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
AbstractContainerBaseTest.LOCAL_STACK_CONTAINER.getEndpoint().toString(),
Expand All @@ -32,5 +44,26 @@ public AmazonS3 amazonS3() {
)
)
.build();
init(amazonS3);
return amazonS3;
}

public void init(AmazonS3 amazonS3) {
log.info("creating the {} bucket...", bucketName);
Bucket bucket = amazonS3.createBucket(bucketName);
log.info("success the bucket : {}", bucket.toString());

// dividends.csv 파일 저장
try {
amazonS3.putObject(new PutObjectRequest(
bucketName,
"dividend/dividends.csv",
new ClassPathResource("dividends.csv").getFile()
)
);
} catch (IOException e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -143,6 +144,7 @@ void logout() {
* @param accessTokenCreateDate AccessToken 생성 시간
* @param refreshTokenCreateDate RefreshToken 생성 시간
*/
@Disabled(value = "날짜 이슈로 인한 임시 비활성화")
@DisplayName("사용자는 액세스 토큰이 만료된 상태에서 액세스 토큰을 갱신한다")
@MethodSource(value = {"validJwtTokenCreateDateSource"})
@ParameterizedTest(name = "{index} ==> the tokenCreateDate is {0}, {1} ")
Expand Down Expand Up @@ -201,6 +203,7 @@ public static Stream<Arguments> validJwtTokenCreateDateSource() {
* @param accessTokenCreateDate AccessToken 생성 시간
* @param refreshTokenCreateDate RefreshToken 생성 시간
*/
@Disabled(value = "날짜 이슈로 인한 임시 비활성화")
@DisplayName("사용자는 리프레시 토큰이 만료된 상태에서는 액세스 토큰을 갱신할 수 없다")
@MethodSource(value = {"invalidJwtTokenCreateDateSource"})
@ParameterizedTest(name = "{index} ==> the tokenCreateDate is {0}, {1} ")
Expand Down

0 comments on commit f464c5f

Please sign in to comment.