Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat(Dockerfile): 배포 설정 (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
goldentrash authored Jan 27, 2024
1 parent 35cf3b6 commit a044ad2
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/Continuous Delivery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Continuous Delivery

on:
pull_request:
branches:
- 'main'

jobs:
Delivery:
runs-on: ubuntu-22.04

env:
DB_URL: ${{ secrets.DB_URL }}
DB_USER: ${{ secrets.DB_USR }}
DB_PASSWORD: ${{ secrets.DB_PWD }}

steps:
- name: Set up sources
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
submodules: true

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: corretto
cache: gradle

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Execute Gradle build
run: ./gradlew build

- name: Login to docker-hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build Docker Image
run: docker build --tag goldentrash/plantory:latest .

- name: Push docker image
run: docker push goldentrash/plantory:latest
33 changes: 33 additions & 0 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy

on:
pull_request:
types:
- closed
branches:
- 'main'

jobs:
Deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04

steps:
# Needed for `google-github-actions`
- uses: 'actions/checkout@v4'

- name: Login to Google
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}

- name: Update docker container
uses: google-github-actions/ssh-compute@v1
with:
instance_name: plantory
zone: asia-northeast3-a
ssh_private_key: ${{ secrets.GCP_SSH_KEY }}
command: |
docker pull goldentrash/plantory:latest
docker stop plantory
docker run -d --rm -p 8080:8080 --mount type=volume,src=resources,dst=/app/resources --name plantory goldentrash/plantory
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# syntax=docker/dockerfile:1

FROM amazoncorretto:17-alpine

WORKDIR /app
COPY /build/libs/plantory-*-SNAPSHOT.jar app.jar

EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ spring:
database: mysql
database-platform: org.hibernate.dialect.MySQLDialect
hibernate:
ddl-auto: create
ddl-auto: validate
properties:
hibernate:
format_sql: true
Expand All @@ -22,7 +22,7 @@ spring:

local:
image:
root: src/test/resources
root: resources

companionPlant:
image:
Expand Down

0 comments on commit a044ad2

Please sign in to comment.