From 68f93fc5ac2ae290ac5dac5f423819440c0dedf8 Mon Sep 17 00:00:00 2001 From: ImSoZRious Date: Wed, 4 Oct 2023 17:46:33 +0700 Subject: [PATCH] feat(ci): build image --- .dockerignore | 3 +++ .github/workflows/ci.yaml | 33 +++++++++++++++++++++++++++++++++ Dockerfile | 9 +++++++++ 3 files changed, 45 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/ci.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8d67a86 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.DS_Store +node_modules +dist diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..a57a2d3 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,33 @@ +name: 'Build static sites image' + +on: + push: + branches: + - main + +jobs: + build_image: + name: Build docker image + runs-on: + - ubuntu-latest + permissions: + content: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to the Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build image + uses: docker/build-push-action@v5 + with: + context: . + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fa95824 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM node:lts AS build +WORKDIR /app +COPY . . +RUN npm i +RUN npm run build + +FROM httpd:2.4-alpine AS runtime +COPY --from=build /app/dist /usr/local/apache2/htdocs/ +EXPOSE 80