-
Notifications
You must be signed in to change notification settings - Fork 0
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
Deploy/#52-deploy-docker-file #56
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b83fc20
deploy: workflow using dockerhub
Sion99 1fb16d0
chore: rename workflow file
Sion99 16ad070
chore: rename workflow file
Sion99 cdc3a46
Merge branch 'deploy/#52-deploy-docker-file' of https://github.com/Pr…
Sion99 65802a7
deploy: workflow using scp-action
Sion99 bd3e64c
add: add Dockerfile
Sion99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,21 +4,29 @@ | |
# documentation. | ||
# 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: Deploy Backend on Development Server | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
HOST: ${{ secrets.HOST }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
KEY: ${{ secrets.KEY }} | ||
PORT: ${{ secrets.PORT }} | ||
INSTANCE_PATH: ./backend-dev | ||
IMAGE_NAME: shinsion/uspray-server | ||
|
||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
|
@@ -43,3 +51,27 @@ jobs: | |
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
|
||
- name: Dockerhub login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Docker image build and push | ||
run: | | ||
docker build -t ${{ env.IMAGE_NAME }} . | ||
docker push ${{ env.IMAGE_NAME }} | ||
|
||
- name: Pull docker image to server | ||
uses: appleboy/ssh-action@master | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 이 appleboy는 뭔가요? 어렵네요 .. |
||
with: | ||
host: ${{ env.HOST }} | ||
username: ${{ env.USERNAME }} | ||
key: ${{ env.KEY }} | ||
port: ${{ env.PORT }} | ||
script: | | ||
docker stop uspray-server | ||
docker rm uspray-server | ||
docker rmi ${{ env.IMAGE_NAME }}: latest | ||
docker-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# 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: Deploy Backend on Development Server | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
HOST: ${{ secrets.HOST }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
KEY: ${{ secrets.KEY }} | ||
PORT: ${{ secrets.PORT }} | ||
INSTANCE_PATH: ./backend-dev | ||
IMAGE_NAME: shinsion/uspray-server | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
- name: Make gradlew executable | ||
run: chmod +x ./gradlew # Gradle 스크립트 파일에 실행 권한을 부여합니다. | ||
|
||
- name: Create application.yml | ||
run: | | ||
mkdir -p ./src/main/resources | ||
cd ./src/main/resources | ||
echo "${{ secrets.APPLICATION }}" base64 -d > application.yml | ||
|
||
- name: Create service-account-file.json | ||
run: | | ||
mkdir -p ./src/main/resources/firebase | ||
cd ./src/main/resources/firebase | ||
echo "${{ secrets.SERVICE_ACCOUNT_FILE }}" base64 -d > service-account-file.json | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
|
||
- name: Dockerhub login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Docker image build and push | ||
run: | | ||
docker build -t ${{ env.IMAGE_NAME }} . | ||
docker push ${{ env.IMAGE_NAME }} | ||
|
||
- name: Pull docker image to server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ env.HOST }} | ||
username: ${{ env.USERNAME }} | ||
key: ${{ env.KEY }} | ||
port: ${{ env.PORT }} | ||
script: | | ||
docker stop uspray-server | ||
docker rm uspray-server | ||
docker rmi ${{ env.IMAGE_NAME }}: latest | ||
docker-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM openjdk:11-jdk | ||
|
||
WORKDIR /app | ||
|
||
ARG JAR_FILE=build/libs/uspray-0.0.1-SNAPSHOT.jar | ||
|
||
COPY ${JAR_FILE} . | ||
|
||
ENTRYPOINT ["java","-jar","uspray-0.0.1-SNAPSHOT.jar"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
시온님 도커허브에 이미지가 올라가는 거죠? 기존에는 규민오빠 계정에 올라가있었나요? @mulmuri