diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml new file mode 100644 index 0000000..39a4942 --- /dev/null +++ b/.github/workflows/docker-ci.yml @@ -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 \ No newline at end of file diff --git a/multistage.Dockerfile b/multistage.Dockerfile new file mode 100644 index 0000000..edb2321 --- /dev/null +++ b/multistage.Dockerfile @@ -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;"] \ No newline at end of file