Skip to content

Commit

Permalink
Build both pnpm and yarn images
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Sep 10, 2024
1 parent 065c7aa commit 9a24690
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 110 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/image-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ on:
required: false
type: boolean
default: false
suffix:
required: false
type: string
default: ""
secrets:
registry-username:
required: true
registry-password:
required: true

jobs:

release:
runs-on: [self-hosted, ARM64, stable]
environment: DOCKER_HUB
Expand All @@ -46,6 +49,7 @@ jobs:
${{ inputs.image-name }}
flavor: |
latest=false
suffix=${{ inputs.suffix }}
tags: |
type=ref,event=branch
type=ref,event=pr
Expand Down
55 changes: 0 additions & 55 deletions .github/workflows/nightly.yml

This file was deleted.

76 changes: 67 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release new Docker image
on:
push:
tags:
- 'v*'
- "v*"
workflow_dispatch:

env:
Expand All @@ -12,7 +12,6 @@ env:
IS_LATEST: false

jobs:

meta:
runs-on: ubuntu-latest
outputs:
Expand All @@ -33,7 +32,7 @@ jobs:
echo "IS_LATEST=$IS_LATEST" >> $GITHUB_OUTPUT
echo "VOLTO_VERSION=$(cat version.txt)" >> $GITHUB_OUTPUT
builder-image:
pnpm-builder-image:
needs:
- meta
uses: ./.github/workflows/image-release.yml
Expand All @@ -47,7 +46,7 @@ jobs:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}

prod-conf-image:
pnpm-prod-conf-image:
uses: ./.github/workflows/image-release.yml
with:
volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }}
Expand All @@ -62,7 +61,7 @@ jobs:
needs:
- meta

dev-image:
pnpm-dev-image:
uses: ./.github/workflows/image-release.yml
with:
volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }}
Expand All @@ -75,9 +74,9 @@ jobs:
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
needs:
- meta
- builder-image
- pnpm-builder-image

plone-frontend:
pnpm-plone-frontend:
uses: ./.github/workflows/image-release.yml
with:
volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }}
Expand All @@ -90,5 +89,64 @@ jobs:
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
needs:
- meta
- builder-image
- prod-conf-image
- pnpm-builder-image
- pnpm-prod-conf-image

yarn-builder-image:
needs:
- meta
uses: ./.github/workflows/image-release.yml
with:
volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }}
image-name: ${{ needs.meta.outputs.BASE_IMAGE_NAME }}-builder
dockerfile: Dockerfile.builder
platforms: ${{ needs.meta.outputs.PLATFORMS }}
suffix: -yarn
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}

yarn-prod-conf-image:
uses: ./.github/workflows/image-release.yml
with:
volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }}
image-name: ${{ needs.meta.outputs.BASE_IMAGE_NAME }}-prod-config
dockerfile: Dockerfile.prod
platforms: ${{ needs.meta.outputs.PLATFORMS }}
suffix: -yarn
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
needs:
- meta

yarn-dev-image:
uses: ./.github/workflows/image-release.yml
with:
volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }}
image-name: ${{ needs.meta.outputs.BASE_IMAGE_NAME }}-dev
dockerfile: Dockerfile.dev
platforms: ${{ needs.meta.outputs.PLATFORMS }}
suffix: -yarn
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
needs:
- meta
- yarn-builder-image

yarn-plone-frontend:
uses: ./.github/workflows/image-release.yml
with:
volto-version: ${{ needs.meta.outputs.VOLTO_VERSION }}
image-name: plone/plone-frontend
dockerfile: Dockerfile
platforms: ${{ needs.meta.outputs.PLATFORMS }}
suffix: -yarn
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
needs:
- meta
- yarn-builder-image
- yarn-prod-conf-image
4 changes: 1 addition & 3 deletions .github/workflows/runnertest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ on:
workflow_dispatch:

jobs:

release:
runs-on: [self-hosted, ARM64, Linux, unstable]
environment: DOCKER_HUB

steps:

- name: Checkout
uses: actions/checkout@v4

Expand Down Expand Up @@ -45,7 +43,7 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
context: .
file: Dockerfile.nightly
file: Dockerfile.builder
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
38 changes: 0 additions & 38 deletions Dockerfile.nightly

This file was deleted.

22 changes: 22 additions & 0 deletions pnpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# syntax=docker/dockerfile:1
ARG VOLTO_VERSION
FROM plone/frontend-builder:${VOLTO_VERSION} as builder

# Build Volto Project and then remove directories not needed for production
COPY pnpm-workspace.yaml /app/
RUN --mount=type=cache,id=pnpm,target=/app/.pnpm-store/uid=1000 <<EOT
set -e
pnpm build
rm -rf node_modules
pnpm install --prod
EOT

FROM plone/frontend-prod-config:${VOLTO_VERSION} as base

LABEL maintainer="Plone Community <[email protected]>" \
org.label-schema.name="plone-frontend" \
org.label-schema.description="Plone frontend image" \
org.label-schema.vendor="Plone Foundation"

# Copy Volto project
COPY --from=builder /app/ /app/
36 changes: 36 additions & 0 deletions pnpm/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# syntax=docker/dockerfile:1
FROM node:20-slim
ARG VOLTO_VERSION
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

LABEL maintainer="Plone Community <[email protected]>" \
org.label-schema.name="frontend-base" \
org.label-schema.description="Plone frontend builder image" \
org.label-schema.vendor="Plone Foundation"

RUN <<EOT
set -e
apt update
apt install -y --no-install-recommends python3 python3-pip build-essential git ca-certificates pipx
rm -rf /var/lib/apt/lists/*
EOT

RUN <<EOT
set -e
pipx run --no-cache cookieplone sub/frontend_project --no_input __version_plone_volto=$VOLTO_VERSION
chown -R node:node /app
EOT

COPY --chown=node:node volto.config.js /app/

RUN corepack enable
USER node

WORKDIR /app
RUN --mount=type=cache,id=pnpm,target=/app/.pnpm-store,uid=1000 <<EOT
set -e
git clone -b $VOLTO_VERSION --depth 1 https://github.com/plone/volto core
pnpm install
EOT
2 changes: 1 addition & 1 deletion Dockerfile.dev → pnpm/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WORKDIR /app
EXPOSE 3000 3001 6006

# Entrypoint would be yarn
ENTRYPOINT [ "yarn" ]
ENTRYPOINT [ "pnpm" ]

# Run the project in development mode
CMD ["start"]
40 changes: 40 additions & 0 deletions pnpm/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# syntax=docker/dockerfile:1
FROM node:20-slim

LABEL maintainer="Plone Community <[email protected]>" \
org.label-schema.name="frontend-prod-config" \
org.label-schema.description="Slim image for Plone frontend deployments" \
org.label-schema.vendor="Plone Foundation"


# Install busybox and wget
RUN <<EOT
set -e
apt update
apt install -y --no-install-recommends busybox wget git
busybox --install -s
rm -rf /var/lib/apt/lists/*
mkdir /app
chown -R node:node /app
EOT

RUN corepack enable

# Run the image with user node
USER node

# Set working directory to /app
WORKDIR /app
RUN corepack use pnpm@9

# Expose default Express port
EXPOSE 3000

# Set healthcheck to port 3000
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s CMD [ -n "$LISTEN_PORT" ] || LISTEN_PORT=3000 ; wget -q http://127.0.0.1:"$LISTEN_PORT" -O - || exit 1

# Entrypoint would be pnpm
ENTRYPOINT [ "pnpm" ]

# And the image will run in production mode
CMD ["start:prod"]
10 changes: 10 additions & 0 deletions pnpm/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
packages:
# all packages in direct subdirs of packages/
- "core/packages/volto"
- "core/packages/types"
- "core/packages/registry"
- "core/packages/scripts"
- "core/packages/tsconfig"
- "core/packages/volto-slate"
- "core/packages/coresandbox"
- "packages/*"
7 changes: 7 additions & 0 deletions pnpm/volto.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const addons = [];
const theme = "";

module.exports = {
addons,
theme,
};
Loading

0 comments on commit 9a24690

Please sign in to comment.