Skip to content

Commit

Permalink
Docker CI Pipeline 추가 (#219)
Browse files Browse the repository at this point in the history
* ci: Add CI/CD support for Docker image building and pushing

* chore: Configure Docker multi-stage build for application

* fix: Update Docker multi-stage build for the application

* fix: Update Docker multi-stage file

* fix: Removed the 'ci/docker-ci-pipeline' branch from the list of branches to trigger the workflow.

* fix: Docker Build Update with Environment Profile Setting

* refactor: Update Docker ci Pipeline

* test: Docker ci Pipeline

* refactor: Removed the 'ci/docker-ci-pipeline' branch from the list of branches to trigger the workflow.

* refactor(#219): Builds and pushes development images only

* refactor(#219): Builds and pushes prod images only

* refactor(#219): Added a step to create a release when pushing to the 'dev' branch.

* test(#219): Commented out the condition for creating a release on the 'dev' branch push.

* test(#219): Commented out the condition for creating a release on the 'dev' branch push. ImKunYoung 38 minutes ago

* ci(#219): Added comments to explain the steps in creating the GitHub release

ci(#219): Added comments to explain the steps in creating the GitHub release

* ci(#219): Handled the case where there is no previous release available

* test(#219): Test generateReleaseNotes Opt

* test(#219): Update Create GitHub Release Step

* fix(#219): Update Docker Dev Image release tag format in docker-ci-dev.yml
  • Loading branch information
ImKunYoung authored Sep 22, 2023
1 parent a8e29f5 commit 59469d6
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docker-ci-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and Push Docker Dev Image

on:
push:
branches:
- dev

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create src/main/resources/bootstrap.yml
run: |
mkdir -p src/main/resources
echo "encrypt:" > src/main/resources/bootstrap.yml
echo " key: '${{ secrets.ENCRYPTKEY }}'" >> src/main/resources/bootstrap.yml
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GTOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Create Release Name
id: release_name
run: |
echo "::set-output name=release_name::v-$(date +'%Y.%m.%d-%H%M%S')"
- name: Build And Push Docker Dev Image
run: |
RELEASE_NAME="${{ steps.release_name.outputs.release_name }}"
docker build --build-arg SPRING_PROFILES_ACTIVE=dev -t my-product-server:latest -f multistage.Dockerfile .
docker tag my-product-server:latest ghcr.io/liberty52/liberty52-product-server:dev$RELEASE_NAME
docker push ghcr.io/liberty52/liberty52-product-server:dev$RELEASE_NAME
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.release_name.outputs.release_name }}
release_name: Release ${{ steps.release_name.outputs.release_name }}
generateReleaseNotes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GTOKEN }}

- name: Clean up
run: docker logout ghcr.io
32 changes: 32 additions & 0 deletions .github/workflows/docker-ci-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Push Docker Prod Image

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create src/main/resources/bootstrap.yml
run: |
mkdir -p src/main/resources
echo "encrypt:" > src/main/resources/bootstrap.yml
echo " key: '${{ secrets.ENCRYPTKEY }}'" >> src/main/resources/bootstrap.yml
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GTOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and Push Docker Prod Image
run: |
docker build --build-arg SPRING_PROFILES_ACTIVE=prod -t my-product-server:latest -f multistage.Dockerfile .
docker tag my-product-server:latest ghcr.io/liberty52/liberty52-product-server:prod-v${{ github.sha }}
docker push ghcr.io/liberty52/liberty52-product-server:prod-v${{ github.sha }}
- name: Clean up
run: docker logout ghcr.io
15 changes: 15 additions & 0 deletions multistage.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM gradle:7.4-jdk17 AS builder
WORKDIR /app
COPY build.gradle .
COPY settings.gradle .
COPY src src
RUN gradle assemble

FROM openjdk:17-alpine
VOLUME /tmp
ARG JAR_FILE=/app/build/libs/*.jar
COPY --from=builder ${JAR_FILE} app.jar
EXPOSE 8080
ARG SPRING_PROFILES_ACTIVE=dev
ENV SPRING_PROFILES_ACTIVE=$SPRING_PROFILES_ACTIVE
ENTRYPOINT ["java","-jar", "app.jar","-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}"]

0 comments on commit 59469d6

Please sign in to comment.