Skip to content

Commit

Permalink
Merge pull request #175 from makevook/release
Browse files Browse the repository at this point in the history
main 병합
  • Loading branch information
seungyeop-lee authored Jul 23, 2024
2 parents 52d3893 + e0a632c commit eb8e8bd
Show file tree
Hide file tree
Showing 64 changed files with 649 additions and 1,223 deletions.
24 changes: 16 additions & 8 deletions cicd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ deploy-prod:
--version=${VERSION} \
--command="make deploy-api"

.PHONY:build-jar
build-jar:
dagger call -v build-api-jar --dir=../server --test --sub-module=api export --path out/api.jar
.PHONY:build-api-jar
build-api-jar:
dagger call -v build-jar --dir=../server --test --sub-module=api export --path out/api.jar

.PHONY:build-image
build-image: build-jar
dagger call -v build-api-image --jar-file=out/api.jar export --path out/api_linux_arm64.tar
.PHONY:build-api-image
build-api-image:
dagger call -v build-image --jar-file=out/api.jar --name=api export --path out/api_linux_arm64.tar

.PHONY:run-jar
run-jar:
.PHONY:run-api-jar
run-api-jar:
(cd out && java -jar api.jar)

.PHONY:build-sync-jar
build-sync-jar:
dagger call -v build-jar --dir=../server --test --sub-module=sync export --path out/sync.jar

.PHONY:run-sync-jar
run-sync-jar:
(cd out && java -jar sync.jar)
16 changes: 9 additions & 7 deletions cicd/dagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type VookServer struct{}

func (v *VookServer) BuildApiJar(
func (v *VookServer) BuildJar(
ctx context.Context,
// 빌드 대상의 디렉토리
dir *dagger.Directory,
Expand Down Expand Up @@ -51,17 +51,19 @@ func (v *VookServer) BuildApiJar(

jarFile := c.
WithExec(bootJarCommand).
File("jar/api.jar")
File(fmt.Sprintf("jar/%s.jar", subModule))

return jarFile, nil
}

func (v *VookServer) BuildApiImage(
func (v *VookServer) BuildImage(
// jar 파일
jarFile *dagger.File,
// profile
// +optional
profile []string,
// 이미지 이름
name string,
) *dagger.File {
if profile == nil {
profile = []string{"default"}
Expand All @@ -85,9 +87,9 @@ ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=` + strings.Join(profile,
Platform: []dagger.Platform{"linux/arm64"},
}).
Save(dagger.DockerBuildSaveOpts{
Name: "api",
Name: name,
}).
File("api_linux_arm64.tar")
File(fmt.Sprintf("%s_linux_arm64.tar", name))
}

func (v *VookServer) SendImage(
Expand Down Expand Up @@ -162,12 +164,12 @@ func (v *VookServer) Deploy(
version string,
command string,
) error {
jarFile, err := v.BuildApiJar(ctx, sourceDir, true, "api")
jarFile, err := v.BuildJar(ctx, sourceDir, true, "api")
if err != nil {
return err
}

imageTar := v.BuildApiImage(jarFile, []string{"default", profile})
imageTar := v.BuildImage(jarFile, []string{"default", profile}, "api")

err = v.SendImage(ctx, sshDest, sshKey, targetPath, imageTar)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion devenv/sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package vook.server.api.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.keyvalue.repository.KeyValueRepository;

@Configuration
@EnableJpaAuditing
@EnableJpaRepositories(
basePackages = "vook.server.api",
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {KeyValueRepository.class})
)
public class JpaConfig {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import vook.server.api.infra.vocabulary.cache.UserVocabularyCacheRepository;

@Configuration
@EnableRedisRepositories(basePackageClasses = UserVocabularyCacheRepository.class)
public class RedisConfig {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@ApplicationModule(
type = ApplicationModule.Type.OPEN,
allowedDependencies = {
"vook.server.api.web.common"
"vook.server.api.web.common",
"vook.server.api.infra"
}
)
package vook.server.api.config;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package vook.server.api.devhelper.app.init;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.devhelper.app.sync.SyncService;
import vook.server.api.domain.user.model.social_user.SocialUserRepository;
import vook.server.api.domain.user.model.user.UserRepository;
import vook.server.api.domain.user.model.user_info.UserInfoRepository;
import vook.server.api.domain.vocabulary.model.term.TermRepository;
import vook.server.api.infra.vocabulary.cache.UserVocabularyCacheRepository;
import vook.server.api.infra.vocabulary.jpa.VocabularyJpaRepository;

@Service
@Transactional
@RequiredArgsConstructor
public class InitService {

private final TermRepository termRepository;
private final VocabularyJpaRepository vocabularyJpaRepository;
private final UserVocabularyCacheRepository userVocabularyCacheRepository;
private final UserInfoRepository userInfoRepository;
private final SocialUserRepository socialUserRepository;
private final UserRepository userRepository;

private final SyncService syncService;

public void init() {
deleteAllUserData();
syncService.sync();
}

private void deleteAllUserData() {
// 용어집
termRepository.deleteAllInBatch();
vocabularyJpaRepository.deleteAllInBatch();
userVocabularyCacheRepository.deleteAll();

// 사용자
userInfoRepository.deleteAllInBatch();
socialUserRepository.deleteAllInBatch();
userRepository.deleteAllInBatch();
}
}
Loading

0 comments on commit eb8e8bd

Please sign in to comment.