From 94c78a0d067471500af7f20477ffaabbab8b7ba9 Mon Sep 17 00:00:00 2001 From: Samuel Mwangi Date: Mon, 18 Mar 2024 23:18:50 +0300 Subject: [PATCH] Build docker image and push to ghcr --- .github/workflows/build-docs-image.yaml | 34 +++++++++++++++++++++++++ docs/Dockerfile | 18 +++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/build-docs-image.yaml create mode 100644 docs/Dockerfile diff --git a/.github/workflows/build-docs-image.yaml b/.github/workflows/build-docs-image.yaml new file mode 100644 index 0000000..7cd1d45 --- /dev/null +++ b/.github/workflows/build-docs-image.yaml @@ -0,0 +1,34 @@ +name: Build Docs Image & Deploy to GHCR + +on: + push: + branches: + - main + - add-docs + workflow_dispatch: + +jobs: + push-store-image: + runs-on: ubuntu-latest + defaults: + run: + working-directory: './docs' + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@main + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/samuelmwangiw/at-laravel-docs:latest diff --git a/docs/Dockerfile b/docs/Dockerfile new file mode 100644 index 0000000..9a87a66 --- /dev/null +++ b/docs/Dockerfile @@ -0,0 +1,18 @@ +FROM node:lts-alpine as build + +WORKDIR /app + +COPY . . + +RUN apk add --no-cache git && \ + npm ci && \ + npm run docs:build + +FROM nginx:stable-alpine + +LABEL org.opencontainers.image.source="https://github.com/SamuelMwangiW/africastalking-laravel" +LABEL org.opencontainers.image.licenses="MIT" + +COPY --from=build /app/.vitepress/dist /usr/share/nginx/html + +EXPOSE 80