Skip to content

Commit

Permalink
readme-for-app-demo-gif (#43)
Browse files Browse the repository at this point in the history
* feature: readme

* fix: git actions rmq settings

* fix: delete previos container via docker stop

* feature: ApplicationStartup PostConstruct Instant

* fix: build and push first

* fix: docker image name

* fix: gradlew build

* fix: build in local

* fix: remove docker build from script
  • Loading branch information
bviz6542 authored Jul 28, 2024
1 parent 791188e commit 7902174
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ jobs:
script: |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker pull ${{ secrets.DOCKER_IMAGE }}:latest
EXISTING_CONTAINER=$(sudo docker ps --filter "publish=8080" -q)
if [ ! -z "$EXISTING_CONTAINER" ]; then
echo "Stopping and removing existing container on port 8080"
sudo docker stop $EXISTING_CONTAINER
sudo docker rm $EXISTING_CONTAINER
fi
sudo docker rm -f ${{ secrets.CONTAINER_NAME }} || true
sudo docker run -d -p 8080:8080 --name ${{ secrets.CONTAINER_NAME }} \
-e RMQ_HOST=${{ secrets.RMQ_HOST }} \
-e RMQ_PORT=${{ secrets.RMQ_PORT }} \
-e RMQ_USERNAME=${{ secrets.RMQ_USERNAME }} \
-e RMQ_PASSWORD=${{ secrets.RMQ_PASSWORD }} \
-e MYSQL_URL=${{ secrets.MYSQL_URL }} \
-e MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} \
-e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} \
Expand Down
5 changes: 5 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p align="center">
<img src="https://github.com/user-attachments/assets/a00863d4-83f6-4310-a2ba-f5d94b955ae1">
</br> </br>
<b>two friends gathering</b>
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.swiftgathering_server.config;

import lombok.Getter;
import org.springframework.stereotype.Component;

import jakarta.annotation.PostConstruct;
import java.time.Instant;

@Component
public class ApplicationStartup {
@Getter
private static Instant startTime;

@PostConstruct
public void onStartup() {
startTime = Instant.now();
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
package com.example.swiftgathering_server.controller;

import com.example.swiftgathering_server.config.ApplicationStartup;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

@Controller
@RequestMapping("/health")
public class HealthController {
@GetMapping
public ResponseEntity<String> checkHealth() {
return ResponseEntity
.ok("v1.0.6");
Instant bootTime = ApplicationStartup.getStartTime();
ZonedDateTime bootTimeKST = bootTime.atZone(ZoneId.of("Asia/Seoul"));
String bootTimeFormatted = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z").format(bootTimeKST);
String response = String.format("boot time: %s", bootTimeFormatted);
return ResponseEntity.ok(response);
}
}
}

0 comments on commit 7902174

Please sign in to comment.