From 0228d14622db568255d173b039818911fa492f0c Mon Sep 17 00:00:00 2001 From: SanttuA Date: Fri, 11 Oct 2024 13:30:37 +0300 Subject: [PATCH] GitHub workflow to build frontend image (#1) Added a workflow to trigger docker image build and push to Github container registry for frontend. Added frontend envs to dockerfile. --- .github/workflows/publish-front-image.yaml | 47 ++++++++++++++++++++++ frontend/Dockerfile | 10 +++++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/publish-front-image.yaml diff --git a/.github/workflows/publish-front-image.yaml b/.github/workflows/publish-front-image.yaml new file mode 100644 index 0000000..fc424cf --- /dev/null +++ b/.github/workflows/publish-front-image.yaml @@ -0,0 +1,47 @@ +name: Publish Frontend Image to GHCR + +on: + workflow_dispatch: + inputs: + tag: + description: 'Image tag' + required: true + default: 'latest' + +env: + IMAGE_NAME: frontend + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ github.event.inputs.tag }} + type=sha,prefix={{date 'YYYYMMDD'}}- + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: ./frontend + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 5017f0d..ff2c97c 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -8,6 +8,16 @@ RUN npm cache clean --force && npm ci # Build the application COPY . . + +ARG NEXT_PUBLIC_CHAT_API=http://localhost:8000/api/chat +ENV NEXT_PUBLIC_CHAT_API=$NEXT_PUBLIC_API_URL + +ARG NEXT_PUBLIC_USE_LLAMACLOUD=false +ENV NEXT_PUBLIC_USE_LLAMACLOUD=$NEXT_PUBLIC_USE_LLAMACLOUD + +ARG NEXT_TELEMETRY_DISABLED=1 +ENV NEXT_TELEMETRY_DISABLED=$NEXT_TELEMETRY_DISABLED + RUN npm run build # Production stage