diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..c393f59 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,80 @@ +name: Build And Test + +run-name: ${{ gitea.actor }} is runs ci pipeline + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + # paths-ignore: + # - LICENCE + # - 'docs/**' + # - 'helm/**' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: checkout source code + uses: actions/checkout@v3 + + - name: Retrieve version # tag version + id: img-ver + uses: juliangruber/read-file-action@v1 + with: + path: ./version + + # .env.production 생성 + # URL_PROD + - name: Create env_production + # run: ${{ URL_KUBE_SVC }} > .env.production + run: ${{ URL_PROD }} > .env.production + + + - name: Install Docker // Docker 설치 + run: | + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + if: runner.os == 'Linux' + + - name: Set up Docker Buildx + uses: https://github.com/docker/setup-buildx-action@v1 + + - name: Login to Registry + run: docker login -u ${{ secrets.DOCKER_ID }} -p ${{ secrets.DOCKER_PW }} https://harbor.icurfer.com + + - name: build + run: docker build -t harbor.icurfer.com/msa-demo/msa-fe:${{ steps.img-ver.outputs.content }} . + + - name: Push to Docker + run: docker push harbor.icurfer.com/msa-demo/msa-fe:${{ steps.img-ver.outputs.content }} + + ## pre cd + - name: Setup Kustomize + uses: yokawasa/action-setup-kube-tools@v0.9.2 + with: + kustomize: "3.7.0" + + - name: Checkout kustomize repository + uses: actions/checkout@v3 + with: + repository: "icurfer/cd-msa-fe" + ref: main + token: ${{ secrets.ACTION_TOKEN }} + path: cd-msa-fe + + - name: Update Kubernetes resources + run: | + cd cd-msa-fe/overlays/dev/ + kustomize edit set image \harbor.icurfer.com/msa-demo/msa-fe:\${{ steps.img-ver.outputs.content }} + cat kustomization.yaml + + ## cd commit + - name: Commit files + run: | + cd cd-msa-fe + git config --global user.email "icurfer@gmail.com" + git config --global user.name "icurfer" + git commit -am "Update image tag" + git push -u origin main \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4d29575..e892b23 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,10 @@ .DS_Store .env.local .env.development.local +.env.development .env.test.local .env.production.local +.env.production npm-debug.log* yarn-debug.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2aca7dc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Build stage +FROM node:20.11 as builder + +# Set working directory +WORKDIR /usr/src/app + +# Copy package.json and package-lock.json (if available) +COPY package.json package-lock.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application +COPY . ./ + +# Build the application +RUN npm run build + +# Production stage +FROM nginx:alpine + +# Copy the build output to Nginx html directory +COPY --from=builder /usr/src/app/build /usr/share/nginx/html + +# Copy Nginx configuration file +COPY nginx.conf /etc/nginx/nginx.conf + +# Expose port 80 +EXPOSE 80 + +# Start Nginx server +CMD ["nginx", "-g", "daemon off;"] diff --git a/version b/version new file mode 100644 index 0000000..8a9ecc2 --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file