Skip to content

Commit

Permalink
inital setting: connecting db
Browse files Browse the repository at this point in the history
  • Loading branch information
singsangssong committed Jan 8, 2025
1 parent 95563ea commit 4fe1b29
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 3000 -> 80 포트로 수행하도록 지정
- name: Docker run
# 8000 -> 80 포트로 수행하도록 지정
# - name: Docker run
# run: |
# sudo docker stop ${{ env.NAME }} || true
# sudo docker rm ${{ env.NAME }} || true
# sudo docker rmi ${{ env.DOCKER_IMAGE }}:latest || true
# sudo docker run -d -p 80:8080 --name ruty-server --restart always ${{ env.DOCKER_IMAGE }}:latest

# 기존 컨테이너 종료 후 새로운 컨테이너 실행
- name: Deploy Application
run: |
sudo docker stop ${{ env.NAME }} || true
sudo docker rm ${{ env.NAME }} || true
sudo docker rmi ${{ env.DOCKER_IMAGE }}:latest || true
sudo docker run -d -p 80:8080 --name ruty-server --restart always ${{ env.DOCKER_IMAGE }}:latest
docker-compose down || true
docker-compose pull || true
docker-compose up -d || true
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ COPY build/libs/ruty-server-0.0.1-SNAPSHOT.jar /app/app.jar
ENV JAVA_OPTS="-Dserver.port=8080"
ENV PORT=8080

ENV SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/ruty-db
ENV SPRING_DATASOURCE_USERNAME=ruty
ENV SPRING_DATASOURCE_PASSWORD=bunnies

# Expose the application port
EXPOSE 8080

Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "3.8"
services:
mysql:
image: mysql:8.0
container_name: mysql-container
restart: always
environment:
MYSQL_DATABASE: ruty_db
MYSQL_USER: ruty
MYSQL_PASSWORD: bunnies
volumes:
- db_data:/var/lib/mysql
- ./db/conf.d:/etc/mysql/conf.d
ports:
- "3307:3306"

ruty-server:
image: ghcr.io/singsangssong/ruty-server-deploy:latest
container_name: ruty-server
restart: always
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/ruty-db
SPRING_DATASOURCE_USERNAME: ruty
SPRING_DATASOURCE_PASSWORD: bunnies
ports:
- "80:8080"
depends_on:
- mysql

volumes:
db_data:
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ spring:

datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ruty_db
url: jdbc:mysql://34.59.212.76:3306/ruty_db
url: jdbc:mysql://localhost:3306/ruty_db
# url: jdbc:mysql://34.59.212.76:3306/ruty_db
username: ruty
password: bunnies

Expand Down

0 comments on commit 4fe1b29

Please sign in to comment.