Optimize buildx with layer cache
This commit is contained in:
parent
70b30a4806
commit
3d7088a6bf
4 changed files with 37 additions and 47 deletions
38
.github/workflows/local-build.yaml
vendored
38
.github/workflows/local-build.yaml
vendored
|
|
@ -12,23 +12,43 @@ on:
|
||||||
|
|
||||||
# Allow run workflow manually from Action tab
|
# Allow run workflow manually from Action tab
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
IMAGE_VER:
|
||||||
|
description: "version for build image"
|
||||||
|
type: string
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: docker.frappet.com
|
REGISTRY: docker.frappet.com
|
||||||
CMS_IMAGE_NAME: demo/qualifying-exam-cms
|
IMAGE_NAME: demo/qualifying-exam-cms
|
||||||
CMS_IMAGE_TAG: 0.1.1
|
|
||||||
jobs:
|
jobs:
|
||||||
# act -W .github/workflows/local-build.yaml -j local-image
|
# act workflow_dispatch --reuse -W .github/workflows/local-build.yaml --input IMAGE_VER=v0.2.4-dev
|
||||||
local-image:
|
local-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: "Check out code"
|
- name: Check out code # checkout only cms is possible but I checkout all
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- name: Gen Version
|
||||||
with:
|
id: gen_ver
|
||||||
node-version: '18'
|
run: |
|
||||||
|
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
|
||||||
|
echo "{\"version\":\"$IMAGE_VER\", \"builddate\":\"$(date +"%Y-%m-%d_%T")\",\"ref_name\":\"$GITHUB_REF\" }" > ./cms/src/lib/ver.json
|
||||||
|
cat ./cms/src/lib/ver.json
|
||||||
|
echo '::set-output name=image_ver::'$IMAGE_VER
|
||||||
|
- name: Debug act
|
||||||
|
if: ${{ env.ACT }}
|
||||||
|
run: |
|
||||||
|
echo $GITHUB_REF
|
||||||
|
echo ${{ steps.gen_ver.outputs.image_ver }}
|
||||||
|
cat ./cms/src/lib/ver.json
|
||||||
|
|
||||||
- name: Build and push docker image
|
- name: Build and push docker image
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: cms
|
context: cms
|
||||||
load: true
|
load: true
|
||||||
tags: ${{env.REGISTRY}}/${{env.CMS_IMAGE_NAME}}:${{env.CMS_IMAGE_TAG}},${{env.REGISTRY}}/${{env.CMS_IMAGE_NAME}}:latest
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
# cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
# cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||||
|
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ node_modules
|
||||||
.prettierrc
|
.prettierrc
|
||||||
.pretieriignore
|
.pretieriignore
|
||||||
.env
|
.env
|
||||||
|
.svelte-kit
|
||||||
|
build
|
||||||
README.md
|
README.md
|
||||||
Dockerfile
|
Dockerfile
|
||||||
docker-compose.yaml
|
docker-compose.yaml
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
# docker build . -t docker.frappet.com/demo/qualifying-exam-cms:latest
|
# docker build . -t docker.frappet.com/demo/qualifying-exam-cms:latest
|
||||||
FROM node:18 as build
|
FROM node:18 as build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
# optimize build speed by copy all .xx folder and
|
||||||
RUN npm ci
|
COPY *.json .
|
||||||
|
COPY *.*s .
|
||||||
|
RUN npm i
|
||||||
|
COPY src ./src
|
||||||
|
RUN ls
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
FROM node:18-alpine
|
FROM node:18-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import { derived, writable } from 'svelte/store'
|
|
||||||
|
|
||||||
export function createUrlStore(ssrUrl) {
|
|
||||||
// Ideally a bundler constant so that it's tree-shakable
|
|
||||||
if (typeof window === 'undefined') {
|
|
||||||
const { subscribe } = writable(ssrUrl)
|
|
||||||
return { subscribe }
|
|
||||||
}
|
|
||||||
|
|
||||||
const href = writable(window.location.href)
|
|
||||||
|
|
||||||
const originalPushState = history.pushState
|
|
||||||
const originalReplaceState = history.replaceState
|
|
||||||
|
|
||||||
const updateHref = () => href.set(window.location.href)
|
|
||||||
|
|
||||||
history.pushState = function () {
|
|
||||||
originalPushState.apply(this, arguments)
|
|
||||||
updateHref()
|
|
||||||
}
|
|
||||||
|
|
||||||
history.replaceState = function () {
|
|
||||||
originalReplaceState.apply(this, arguments)
|
|
||||||
updateHref()
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('popstate', updateHref)
|
|
||||||
window.addEventListener('hashchange', updateHref)
|
|
||||||
|
|
||||||
return {
|
|
||||||
subscribe: derived(href, ($href) => new URL($href)).subscribe
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If you're using in a pure SPA, you can return a store directly and share it everywhere
|
|
||||||
export default createUrlStore()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue