๐ํด๋น ๋ฆฌํฌ์งํ ๋ฆฌ๋ Github Action์ ์ฌ์ฉํ์ฌ ๊ฐ๋จํ CI/CD ํ์ดํ๋ผ์ธ์ ๊ตฌ์ฑํ๊ธฐ ์ํ ๋ฆฌํฌ์งํ ๋ฆฌ์ ๋๋ค.
๊ฐ์ธ ์ค์ต์ฉ์ผ๋ก ์์ฑ ํ์๊ธฐ์ ์๋ชป๋ ๋ถ๋ถ์ด ์กด์ฌํ ์ ์์ต๋๋ค, ์ฐธ๊ณ ํด์ฃผ์ธ์.
์ถ๊ฐ์ ์ผ๋ก Github Action์ ๋ํ ๋ถ๋ถ์ ์๋ตํ์์ผ๋ ์์ค๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์!
๊ธฐ์ | ๋ฒ์ |
---|---|
Java | 17 |
Spring Boot | 3.2.2 |
Docker | 23.0.5 |
AWS EC2 | Amazon Linux 2 |
AWS Code Deploy | X |
- ๊ฐ๋จํ REST API ์์ฑ
- Dockerfile ์์ฑ
- Github Action Script ์์ฑ(CI/CD)
- EC2 ์์ฑ ํ ๋ฐฐํฌ ์งํ
@Slf4j
@RestController
public class CiCdController {
@Value("${app.version:1.0.0}")
private String version;
@GetMapping("/")
public ResponseEntity<Response> init(
@RequestHeader Map<String, String> headerMap,
@RequestHeader("host") String host) {
log.info("Hello CICD! version = {}", version);
log.info("headerMap = {}, host = {}", headerMap, host);
return ResponseEntity
.status(HttpStatus.OK)
.body(Response.builder()
.version(version)
.host(host)
.build()
);
}
@Data
@Builder
public static class Response {
private final String version;
private final String host;
}
}
{
"version": "1.0.0",
"host": "localhost:8080"
}
- ํ ์คํธ๋ฅผ ์ํ ๊ฐ๋จํ REST API ์์ฑ
- ๋ค๋ฅธ๊ฑด ์๊ณ ์์ ๊ฐ๋ค
app version
๊ณผhost
์ ๋ณด๋ฅผ ๋ฐํํ๋ค