Skip to content

Commit

Permalink
Merge pull request #32 from Cambio-Project/pipeline-optimization
Browse files Browse the repository at this point in the history
Pipeline optimizations
-Much faster build through pnpm and caching
-Reduced image size through docker stages
  • Loading branch information
franksn90 authored May 22, 2024
2 parents b4e71f1 + 37ae26e commit e1492e4
Show file tree
Hide file tree
Showing 5 changed files with 9,728 additions and 19 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/dockerBuildAndPush.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Docker build and publish to GHCR

on:
workflow_dispatch:
push:
branches:
- main
Expand All @@ -15,11 +16,11 @@ jobs:
packages: write
steps:
- name: Checkout current Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
Expand All @@ -29,15 +30,15 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
Expand All @@ -47,3 +48,5 @@ jobs:
build-args: |
EXECUTION_ENV=ci
GITHUB_PACKAGE_READ_TOKEN=${{ secrets.PUBLISH_PACKAGES }}
cache-from: type=gha
cache-to: type=gha,mode=max
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
FROM node:18.14.2-slim as base

FROM node:22.2-slim as base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app

COPY . .

RUN npm install
RUN npm run build
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/.output /app/.output

EXPOSE 3000

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: "dashboard-project"

services:
dashboard:
image: ghcr.io/cambio-project/dashboard-vue-23:1.1.0
image: ghcr.io/cambio-project/dashboard-vue-23:1.1.1
container_name: dashboard
ports:
- 8080:3000
Expand Down
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@nuxt/ui": "^2.16.0",
"nuxt": "^3.11.1",
"nuxt-icon": "^0.6.10",
"nuxt-mongoose": "^1.0.5",
"vue": "^3.4.14",
"vue-router": "^4.2.5"
},
"dependencies": {
"@nuxt/ui": "^2.16.0",
"jszip": "^3.10.1",
"mongoose": "^8.2.1",
"vuex": "^4.0.2"
"mongoose": "^8.4.0",
"nuxt": "^3.11.2",
"nuxt-icon": "^0.6.10",
"nuxt-mongoose": "^1.0.6",
"vue": "^3.4.27",
"vue-router": "^4.3.2",
"vuex": "^4.1.0"
}
}
Loading

0 comments on commit e1492e4

Please sign in to comment.