Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,58 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Create buildx builder
run: |
docker buildx create --use --name mybuilder
docker buildx inspect --bootstrap

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

- name: Build & Push Dependency Cache
run: |
docker buildx build \
--builder mybuilder \
--platform linux/amd64 \
--push \
--file Dockerfile \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache \
--target dependencies \
--cache-to type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache,mode=max \
.

- name: Build & Push Final App Image
run: |
docker buildx build \
--builder mybuilder \
--platform linux/amd64 \
--push \
--file Dockerfile \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/assu-app:latest \
--build-arg DEPENDENCY_IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache \
--cache-from type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache \
.

- name: Create application-secret.yml
run: |
mkdir -p ./temp_secret
echo "${{ secrets.APPLICATION_SECRET }}" > ./temp_secret/application-secret.yml
shell: bash

- name: Create service-account.json
run: |
mkdir -p ./temp_secret
echo "${{ secrets.SERVICE_ACCOUNT }}" > ./temp_secret/service-account.json
shell: bash

- name: Copy application-secret.yml to EC2
uses: appleboy/[email protected]
with:
Expand All @@ -26,6 +72,15 @@ jobs:
source: ./temp_secret/application-secret.yml
target: /home/ubuntu/secret/

- name: Copy service-account.json to EC2
uses: appleboy/[email protected]
with:
username: ubuntu
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_SSH_KEY }}
source: ./temp_secret/service-account.json
target: /home/ubuntu/secret/

- name: Copy docker-compose.yml
uses: appleboy/[email protected]
with:
Expand Down
44 changes: 3 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI Pipeline
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
ci:
Expand Down Expand Up @@ -32,44 +34,4 @@ jobs:
run: chmod +x ./gradlew

- name: Build and Test
run: ./gradlew clean build test

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Create buildx builder
run: |
docker buildx create --use --name mybuilder
docker buildx inspect --bootstrap

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

- name: Build & Push Dependency Cache
run: |
docker buildx build \
--builder mybuilder \
--platform linux/amd64 \
--push \
--file Dockerfile \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache \
--target dependencies \
--cache-to type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache,mode=max \
.

- name: Build & Push Final App Image
run: |
docker buildx build \
--builder mybuilder \
--platform linux/amd64 \
--push \
--file Dockerfile \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/assu-app:latest \
--build-arg DEPENDENCY_IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache \
--cache-from type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/assu-app:dependency-cache \
.
run: ./gradlew clean build test --no-build-cache
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ out/

### Secret ###
src/main/resources/application-secret.yml
src/test/resources/application-test.yml
src/test/resources/application-secret.yml

### Firebase ###
src/main/resources/firebase/
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ services:
- SPRING_PROFILES_ACTIVE=blue
- SPRING_CONFIG_ADDITIONAL_LOCATION=file:/app/config/
volumes:
- /home/ubuntu/app/config/application-secret.yml:/app/config/application-secret.yml:ro
- /home/ubuntu/secret/application-secret.yml:/app/config/application-secret.yml:ro
- /home/ubuntu/secret/service-account.json:/app/config/service-account.json:ro
networks:
- assu-network

Expand All @@ -27,7 +28,8 @@ services:
- SPRING_PROFILES_ACTIVE=green
- SPRING_CONFIG_ADDITIONAL_LOCATION=file:/app/config/
volumes:
- /home/ubuntu/app/config/application-secret.yml:/app/config/application-secret.yml:ro
- /home/ubuntu/secret/application-secret.yml:/app/config/application-secret.yml:ro
- /home/ubuntu/secret/service-account.json:/app/config/service-account.json:ro
networks:
- assu-network

Expand Down
Loading