Skip to content

Commit

Permalink
Docker Ci 파이프라인 추가 (#196)
Browse files Browse the repository at this point in the history
* chore: Add multistage.Dockerfile for building and deploying the frontend

* ci: Add GitHub Actions pipeline for building and pushing Docker image

* fix: Update Build Docker image Step

* refactor: Remove unnecessary steps

* refactor: Add Node, npm setting steps

* ci: update

* Changed branch name from 'ci/docker-ci-pipeline' to 'main'

* refactor: Reorganized and simplified the workflow steps

* ci: Added a step to create a GitHub release with release notes.

* ci: Update trigger
  • Loading branch information
ImKunYoung authored Sep 22, 2023
1 parent 17bc32b commit 12cbdc1
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

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

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

- name: Create src/global/url.js
run: |
echo "const SOCIAL_LOGIN_URL = {" > src/global/url.js
echo " KAKAO: '${{ secrets.KAKAO }}'," >> src/global/url.js
echo " NAVER: '${{ secrets.NAVER }}'," >> src/global/url.js
echo " GOOGLE: '${{ secrets.GOOGLE }}'," >> src/global/url.js
echo " FACEBOOK: '${{ secrets.FACEBOOK }}'," >> src/global/url.js
echo "};" >> src/global/url.js
echo "export { SOCIAL_LOGIN_URL };" >> src/global/url.js
- 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 image
run: |
RELEASE_NAME="${{ steps.release_name.outputs.release_name }}"
docker build -t my-frontend-app -f multistage.Dockerfile .
docker tag my-frontend-app ghcr.io/liberty52/liberty52-front-end:dev-$RELEASE_NAME
echo ${{ secrets.GTOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker push ghcr.io/liberty52/liberty52-front-end:dev-$RELEASE_NAME
working-directory: ./

- 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
13 changes: 13 additions & 0 deletions multistage.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
RUN npm run build

FROM nginx:stable-alpine
RUN rm -rf /etc/nginx/conf.d
COPY conf /etc/nginx
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit 12cbdc1

Please sign in to comment.