Skip to content

Commit

Permalink
Merge pull request #47 from plone/pnpm-and-yarn-images
Browse files Browse the repository at this point in the history
Build both pnpm and yarn images
  • Loading branch information
sneridagh authored Sep 13, 2024
2 parents 065c7aa + 36832a1 commit 1b96d0b
Show file tree
Hide file tree
Showing 20 changed files with 214 additions and 122 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.

9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ SHELL:=bash
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules

NIGHTLY_IMAGE_TAG=nightly

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
Expand All @@ -22,7 +20,6 @@ MAIN_IMAGE_NAME=plone/plone-frontend
BASE_IMAGE_NAME=plone/frontend
VOLTO_VERSION=$$(cat version.txt)
IMAGE_TAG=${VOLTO_VERSION}
NIGHTLY_IMAGE_TAG=nightly

# Code Quality
CURRENT_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
Expand Down Expand Up @@ -60,7 +57,6 @@ lint: ## check code style
.PHONY: show-image
show-image: ## Print Version
@echo "$(MAIN_IMAGE_NAME):$(IMAGE_TAG)"
@echo "$(MAIN_IMAGE_NAME):$(NIGHTLY_IMAGE_TAG)"
@echo "$(BASE_IMAGE_NAME)-(builder|dev|prod-config):$(IMAGE_TAG)"

.PHONY: image-builder
Expand All @@ -83,11 +79,6 @@ image-main: ## Build main image
@echo "Building $(MAIN_IMAGE_NAME):$(IMAGE_TAG)"
@docker buildx build . --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t $(MAIN_IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile --load

.PHONY: image-nightly
image-nightly: ## Build Docker Image Nightly
@echo "Building $(MAIN_IMAGE_NAME):$(NIGHTLY_IMAGE_TAG)"
@docker build . -t $(MAIN_IMAGE_NAME):$(NIGHTLY_IMAGE_TAG) -f Dockerfile.nightly

.PHONY: build-images
build-images: ## Build Images
@echo "Building $(BASE_IMAGE_NAME)-(builder|dev|prod):$(IMAGE_TAG) images"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To check and report issues and contribute to Volto, See [plone/volto](https://gi

### Next major version

- `18` [(18.x/Dockerfile)](https://github.com/plone/plone-frontend/blob/18.x/Dockerfile)
- `18`, `18-yarn` [(18.x/Dockerfile)](https://github.com/plone/plone-frontend/blob/18.x/Dockerfile)

### Older tags

Expand Down
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"]
Loading

0 comments on commit 1b96d0b

Please sign in to comment.