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

Feature/docker #33

Merged
merged 18 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 18 additions & 5 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle
name: Java CI with Gradle and Docker for WashPedia Project

on:
push:
Expand All @@ -31,10 +31,12 @@ jobs:

# Gradle Build๋ฅผ ์œ„ํ•œ ๊ถŒํ•œ ๋ถ€์—ฌ
- name: Grant execute permission for gradlew
working-directory: ./module-api
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working-directory์˜ depth ๋ฌธ์ œ์˜€๋‹ค๋Š” ๊ฒƒ์ด๊ตฐ์š”. ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค.

run: chmod +x ./gradlew

# Gradle Build (test ์ œ์™ธ)
- name: Build with Gradle
working-directory: ./module-api
run: ./gradlew clean build -x test

# DockerHub ๋กœ๊ทธ์ธ
Expand All @@ -43,17 +45,28 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# DockerCompose ์„ธํŒ…
- name: Set up Docker Compose
uses: microsoft/variable-substitution@v1
with:
files: ./docker-compose.yml
env:
services.db-edit.environment.POSTGRES_USER: ${{ secrets.POSTGRE_USER }}
services.db-edit.environment.POSTGRES_PASSWORD: ${{ secrets.POSTGRE_PASSWORD }}
services.webapp.image: ${{ secrets.DOCKER_IMAGE }}

# Docker ์ด๋ฏธ์ง€ ๋นŒ๋“œ
- name: Docker Image Build
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROJECT_NAME }} . --platform=linux/amd64
- name: Docker Compose Build
run: docker-compose build

# DockerHub Push
- name: DockerHub Push
run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROJECT_NAME }}
run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROJECT_NAME }}:latest

# deploy:
# runs-on: ubuntu-latest
# steps:
# steps:cd
#
# - name: Application Run
# uses: appleboy/[email protected]
Expand Down
49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3.8'
services:
webapp:
build: ./module-api
image: ${IMAGE}
ports:
- "8080:8080"
depends_on:
- db-edit

# batch:
# build: ./module-batch
# ports:
# - "8082:8080"
# depends_on:
# - db-edit
#
# admin:
# build: ./module-admin
# ports:
# - "8083:8080"
# depends_on:
# - db-read

db-edit:
image: younglong/pg-washpedia:latest
volumes:
- ./postgreReadOnlyDB:/var/lib/postgresql/data
environment:
POSTGRES_DB: edit_db
POSTGRES_USER: ${USER}
POSTGRES_PASSWORD: ${PASSWORD}
ports:
- "5432:5432"

# db-read:
# image: younglong/pg-washpedia:latest
# volumes:
# - postgreEditDB:/var/lib/postgresql/data
# environment:
# POSTGRES_DB: read_db
# POSTGRES_USER: ${{ secrets.PROJECT_USER }}
# POSTGRES_PASSWORD: ${{ secrets.POSTGRE_PASSWORD }}
# ports:
# - "5433:5433"

volumes:
db-read-volume: {}
db-edit-volume: {}
9 changes: 7 additions & 2 deletions module-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM openjdk:17-jdk
CMD ["./gradlew", "clean", "build"]
ARG JAR_FILE=module-api/build/libs/washpedia-0.0.1-SNAPSHOT.jar
ARG JAR_FILE=./build/libs/module-api-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} washpedia.jar
ENTRYPOINT ["java", "-jar", "washpedia.jar"]
ENTRYPOINT ["java", "-jar", "washpedia.jar"]





Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
package com.kernel360.member.controller;

import ch.qos.logback.core.model.Model;

import com.kernel360.member.dto.MemberDto;
import com.kernel360.member.service.MemberService;
import com.kernel360.utils.JWT;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/member/")
@RequestMapping("/member")
public class MemberController {

private final MemberService memberService;

/** ๊ฐ€์ž… **/
@PostMapping("/join")
public ResponseEntity<Model> joinMember (@ModelAttribute MemberDto joinRequestDto){

try{
memberService.joinMember(joinRequestDto);
}catch (IllegalArgumentException args){
log.error("๊ฐ€์ž…์—๋Ÿฌ๋ฐœ์ƒ", args);
}

return new ResponseEntity<>(null, HttpStatus.CREATED);
public String signup(@RequestBody MemberDto memberDto ) {
return "member/signup";
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public record MemberDto(Integer memberNo,
String modifiedBy
) {

/** New All **/
public static MemberDto of(
Integer memberNo,
String id,
Expand All @@ -46,27 +45,6 @@ public static MemberDto of(
);
}

/** joinMember **/
public static MemberDto of(
String id,
String email,
String password
){
return new MemberDto(
null,
id,
email,
password,
null,
null,
null,
null,
null,
null
);
}

/** Entity -> DTO **/
public static MemberDto from(Member entity) {
return MemberDto.of(
entity.getMemberNo(),
Expand All @@ -82,15 +60,14 @@ public static MemberDto from(Member entity) {
);
}

/** DTO -> Entity All binding **/
public static Member toEntity(MemberDto memberDto) {
public Member toEntity(MemberDto memberDto) {
return Member.of(
memberDto.memberNo,
memberDto.id,
memberDto.email,
memberDto.password,
memberDto.gender,
memberDto.birthdate
this.memberNo,
this.id,
this.email,
this.password,
this.gender,
this.birthdate
);
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
package com.kernel360.member.service;

import com.kernel360.member.dto.MemberDto;
import com.kernel360.member.entity.Member;
import com.kernel360.member.repository.MemberRepository;
import com.kernel360.utils.ConvertSHA256;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


@Slf4j
@Service
@RequiredArgsConstructor
public class MemberService {

final private MemberRepository memberRepository;
/** ๊ฐ€์ž… ๋กœ์ง **/
public void joinMember(MemberDto requestDto){

String encodePassword = ConvertSHA256.convertToSHA256(requestDto.password());

Member entity = getNewJoinMemberEntity(requestDto,encodePassword);

memberRepository.save(entity);
}
//package com.kernel360.member.service;
//
//import com.kernel360.member.dto.MemberDto;
//import com.kernel360.member.entity.Member;
//import com.kernel360.member.repository.MemberRepository;
//import com.kernel360.utils.ConvertSHA256;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//
//@Slf4j
//@Service
//@RequiredArgsConstructor
//public class MemberService {
//
// final private MemberRepository memberRepository;
// /** ๊ฐ€์ž… ๋กœ์ง **/
// public void joinMember(MemberDto requestDto){
//
// String encodePassword = ConvertSHA256.convertToSHA256(requestDto.password());
//
// Member entity = getNewJoinMemberEntity(requestDto,encodePassword);
//
// memberRepository.save(entity);
// }

private Member getNewJoinMemberEntity (MemberDto dto, String password){
return Member.createJoinMember(dto.id(),dto.email(),password);
}
// private Member getNewJoinMemberEntity (MemberDto dto, String password){
// return Member.createJoinMember(dto.id(),dto.email(),password);
// }

//
// public void login(){
Expand Down Expand Up @@ -76,4 +76,4 @@ private Member getNewJoinMemberEntity (MemberDto dto, String password){
//// - ํŒจ์Šค์›Œ๋“œ ์žฌ์„ค์ • resetPasswordByAuthKey
//
// }
}
//}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ public List<ProductDto> getProductListByKeyword(String keyword) {

return products.stream().map(ProductDto::from).toList();
}

}
Loading