mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-10 13:26:13 +00:00
Cache docker layers, nextjs builds in dockerize github workflow
This commit is contained in:
8
.github/workflows/dockerize.yml
vendored
8
.github/workflows/dockerize.yml
vendored
@@ -73,7 +73,7 @@ jobs:
|
|||||||
run: rm -rf /opt/hostedtoolcache
|
run: rm -rf /opt/hostedtoolcache
|
||||||
|
|
||||||
- name: 📦 Build and Push Docker Image
|
- name: 📦 Build and Push Docker Image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
if: (matrix.image == 'local' && github.event_name == 'workflow_dispatch') && github.event.inputs.khoj == 'true' || (matrix.image == 'local' && github.event_name == 'push')
|
if: (matrix.image == 'local' && github.event_name == 'workflow_dispatch') && github.event.inputs.khoj == 'true' || (matrix.image == 'local' && github.event_name == 'push')
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -86,9 +86,11 @@ jobs:
|
|||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ steps.hatch.outputs.version }}
|
VERSION=${{ steps.hatch.outputs.version }}
|
||||||
PORT=42110
|
PORT=42110
|
||||||
|
cache-from: type=gha,scope=${{ matrix.image }}
|
||||||
|
cache-to: type=gha,mode=max,scope=${{ matrix.image }}
|
||||||
|
|
||||||
- name: 📦️⛅️ Build and Push Cloud Docker Image
|
- name: 📦️⛅️ Build and Push Cloud Docker Image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
if: (matrix.image == 'cloud' && github.event_name == 'workflow_dispatch') && github.event.inputs.khoj-cloud == 'true' || (matrix.image == 'cloud' && github.event_name == 'push')
|
if: (matrix.image == 'cloud' && github.event_name == 'workflow_dispatch') && github.event.inputs.khoj-cloud == 'true' || (matrix.image == 'cloud' && github.event_name == 'push')
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -101,3 +103,5 @@ jobs:
|
|||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ steps.hatch.outputs.version }}
|
VERSION=${{ steps.hatch.outputs.version }}
|
||||||
PORT=42110
|
PORT=42110
|
||||||
|
cache-from: type=gha,scope=${{ matrix.image }}
|
||||||
|
cache-to: type=gha,mode=max,scope=${{ matrix.image }}
|
||||||
|
|||||||
@@ -38,10 +38,13 @@ FROM node:20-alpine AS web-app
|
|||||||
# Set build optimization env vars
|
# Set build optimization env vars
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
COPY src/interface/web /app/src/interface/web
|
|
||||||
WORKDIR /app/src/interface/web
|
WORKDIR /app/src/interface/web
|
||||||
RUN yarn install --frozen-lockfile && \
|
# Install dependencies first (cache layer)
|
||||||
yarn build
|
COPY src/interface/web/package.json src/interface/web/yarn.lock ./
|
||||||
|
RUN yarn install --frozen-lockfile
|
||||||
|
# Copy source and build
|
||||||
|
COPY src/interface/web/. ./
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
# Merge the Server and Web App into a Single Image
|
# Merge the Server and Web App into a Single Image
|
||||||
FROM base
|
FROM base
|
||||||
|
|||||||
@@ -38,10 +38,13 @@ FROM node:20-alpine AS web-app
|
|||||||
# Set build optimization env vars
|
# Set build optimization env vars
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
COPY src/interface/web /app/src/interface/web
|
|
||||||
WORKDIR /app/src/interface/web
|
WORKDIR /app/src/interface/web
|
||||||
RUN yarn install --frozen-lockfile && \
|
# Install dependencies first (cache layer)
|
||||||
yarn build
|
COPY src/interface/web/package.json src/interface/web/yarn.lock ./
|
||||||
|
RUN yarn install --frozen-lockfile
|
||||||
|
# Copy source and build
|
||||||
|
COPY src/interface/web/. ./
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
# Merge the Server and Web App into a Single Image
|
# Merge the Server and Web App into a Single Image
|
||||||
FROM base
|
FROM base
|
||||||
|
|||||||
Reference in New Issue
Block a user