-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,39 +26,50 @@ jobs: | |
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
# Setup QEMU: https://github.com/docker/setup-qemu-action | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: 'arm64' | ||
|
||
# Workaround: https://github.com/docker/build-push-action/issues/461 | ||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v2 | ||
uses: docker/setup-buildx-action@v6 | ||
with: | ||
install: true | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
path: | | ||
/tmp/.buildx-cache | ||
pnpm-store | ||
# Key is named differently to avoid collision | ||
key: ${{ runner.os }}-multi-buildx-${{ github.sha }} | ||
key: ${{ runner.os }}-multi-buildx-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('Dockerfile') }} | ||
restore-keys: | | ||
${{ runner.os }}-multi-buildx | ||
- name: inject cache into docker | ||
uses: reproducible-containers/[email protected] | ||
with: | ||
cache-map: | | ||
{ | ||
"pnpm-store": "/pnpm/store" | ||
} | ||
skip-extraction: ${{ steps.cache.outputs.cache-hit }} | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
|
@@ -68,7 +79,7 @@ jobs: | |
type=sha | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
|
@@ -80,9 +91,4 @@ jobs: | |
# More: https://github.com/moby/buildkit#--export-cache-options | ||
# And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue | ||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | ||
|
||
# prevents running out of space | ||
- name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
FROM node:lts-slim AS base | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
FROM base AS prod | ||
|
||
COPY pnpm-lock.yaml /app | ||
COPY . /app | ||
WORKDIR /app | ||
RUN pnpm fetch --prod | ||
|
||
COPY . /app | ||
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 /app/node_modules /app/node_modules | ||
COPY --from=prod /app/dist /app/dist | ||
COPY --from=prod-deps /app/node_modules /app/node_modules | ||
COPY --from=build /app/dist /app/dist | ||
CMD [ "pnpm", "start" ] |