Skip to content

Commit

Permalink
Merge pull request #58 from dajeongdev/feature/github-actions
Browse files Browse the repository at this point in the history
chore : docker compose 추가
  • Loading branch information
dajeongdev authored Apr 5, 2024
2 parents b16d917 + 5ea2d27 commit 3e24a8b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
32 changes: 10 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,19 @@ jobs:
run: ./gradlew clean build -x test

# Docker Buildx 설치
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to NCP Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/americanote:latest
cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/americanote:latest
cache-to: type=inline
- name: web docker build and push
run: |
docker login -u ${{ secrets.NCP_ACCESS_KEY }} -p ${{ secrets.NCP_SECRET_KEY }}
docker build -t ${{ secrets.NCP_CONTAINER_REGISTRY }}/americanote_docker .
docker push ${{ secrets.DOCKER_REPO }}/americanote_docker
deploy:
name: Connect server ssh and pull from container registry
needs: build
runs-on: ubuntu-latest

# Access Server & Docker compose up
steps:
- name: Connect ssh
uses: appleboy/ssh-action@master
Expand All @@ -75,8 +63,8 @@ jobs:
password: ${{ secrets.NCP_PASSWORD }}
port: ${{ secrets.NCP_PORT }}
script: |
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/americanote
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 8009:80 --name americanote_docker ${{ secrets.NCP_CONTAINER_REGISTRY }}/americanote
sudo docker rm -f $(docker ps -a -q)
sudo docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/americanote_docker
sudo docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/americanote_nginx
docker-compose up -d
docker image prune -f
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM openjdk:17
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]\
EXPOSE 8009
ENTRYPOINT ["java","-jar","/app.jar"]
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.8'

services:
app:
image: americanote_docker
container_name: app
expose:
- 8009
ports:
- 8009:8009

nginx:
image: americanote_nginx
container_name: nginx
ports:
- 80:80
- 443:443
depends_on:
- app

0 comments on commit 3e24a8b

Please sign in to comment.